Hi.

Just reading about the sqldatareader object I am confused about the
recordsaffected property.

The example on the help docs use a procedure with some inserts and a
select. Can I use a datareader object to run sql commands that does not
return records? What is the advantage of using a
datareader.recordsaffected instead of command.executenonquery, since the
later also can give me the records affected?

Regards,

Chris Leffer



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Re: SqlDataReader recordsaffected by William

William
Tue Sep 16 13:39:21 CDT 2003

Use ExecuteNonQuery if you aren't returning any rows. RecordsAffected is a
property whereas .ExecuteNonQuery is a method, so they aren't the same
thing. ExecuteNonQuery doesn't return a resultset but it will return
Output Parameters and Return Values. Remember though that if you fire a
SELECT statement alone, and it returns say 100 records, you won't know this
from RecordsAffected...you'll hvae to iterate through the reader to find
this out.

HTH

Bill
"Chris Leffer" <chrisl@wank.com> wrote in message
news:uCL09%23HfDHA.2484@TK2MSFTNGP09.phx.gbl...
> Hi.
>
> Just reading about the sqldatareader object I am confused about the
> recordsaffected property.
>
> The example on the help docs use a procedure with some inserts and a
> select. Can I use a datareader object to run sql commands that does not
> return records? What is the advantage of using a
> datareader.recordsaffected instead of command.executenonquery, since the
> later also can give me the records affected?
>
> Regards,
>
> Chris Leffer
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!