我使用microsoft enterprise library 5有以下代码:
Database database = DatabaseFactory.CreateDatabase("myConStr");
int rowsAffected = database.ExecuteNonQuery("[DeleteCustomer]", cboCustomers.SelectedItem.ToString());
myConStr在app.config中定义正确(它适用于其他基于EL的查询)。DeleteCustomer SP定义为:
CREATE PROCEDURE DeleteCustomer
@CustomerID nchar(5)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
delete from dbo.Customers
where CustomerID = @CustomerID
END
在ExecuteNonQuery metod的文档中,结果被称为返回受影响的行数。
然而,我总是得到结果“-1”,即使删除工作良好。怎么了?如何获取已删除记录的数量?
谢谢,
卢西恩