8
Answers

using .RecordsAffected, C#

rocket

rocket

15y
6.2k
1
Hi, I am using a C# application that interacts with a TSQL stored procedure.

The problem is that my SqlDataReader property .RecordsAffected always returns -1 regardless of whatever kind of select, update, or delete query I run.

Here is my relevant code:
 
SqlDataReader myReader = null;

SqlCommand command = new SqlCommand("CSP_CT_233", myConnection);
myReader = command.ExecuteReader();

while (myReader.Read())
        {

           blah blah blah //this stuff works fine
        }

myReader.Close();
Console.Writeline(myReader.RecordsAffected.ToString());
 
Answers (8)