rocket

rocket

  • NA
  • 16
  • 0

using .RecordsAffected, C#

Dec 4 2008 10:54 AM
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)