How to Get Record Count For ExecuteReader();
Posted on 2004-08-29
I know you can get a records affected with ExecuteNonQuery and that you can get a rowcount with ExecuteReader if you are using SqlServer to get an output parameter with the @@ROWCOUNT but I think you can only retreive the @@ROWCOUNTafter closing the connection.
How then can I get some kind of rowcount before the connection closes? For example, I want to say, if there is a record then make myVar1=dr.ToString(); myVar2=dr.ToString(); etc.? If I can only get the @@ROWCOUNT after closing the connection then I can't really set the variables beforehand because there may not be a record existing.
Where and what do I do to the following?:
//If record exists then set these variables: