November 6, 2003 at 9:44 am
How do I retrieve the inserted rows count
using the SqlCommand object in c#
I can execute the sp fine I just need to get the rows inserted returned to the calling method. Thanks.
November 6, 2003 at 9:53 am
use a trigger to return "select count(*) from inserted" and then return that from the SP.
Steve Jones
http://www.sqlservercentral.com/columnists/sjones
The Best of SQL Server Central.com 2002 - http://www.sqlservercentral.com/bestof/
November 6, 2003 at 10:05 am
Thanks for the quick reply Steve. I am new to SQL so im not sure how to do this. Can you explain?
November 7, 2003 at 1:28 am
Use the SqlCommand.ExecuteNonQuery method to run the sp and it will return the number of rows affected by the sp.
November 7, 2003 at 6:51 am
How about an OUTPUT parameter on the procedure? You can set @Output=@@rowcount after the insert statement.
November 7, 2003 at 7:40 am
I'm not sure about c# but with ADO you can check the value of the return value from a procedure.
In the procedure you can add
return @@rowcount
Jeremy
November 7, 2003 at 7:53 am
You can get the return values by adding a parameter named RETVAL and get the value after calling the ExecuteXXXX function...
see the following link for more details
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply