Accessing oledb reader without moving to next record

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I check if an oledb reader returned any records after ExecuteReader,
without fetching the next record?

Thanks

Regards
 
Hi John,

Use a Select string with a Count for the same "where" and use an
executescalar

Cor
 
MyDataReader.HasRows
Repeating the query with a Count? Excuse me? Repeat the whole query process
just to get a count? Expensive, unnecessary and inaccurate. What if a row is
added the instant after your "Count" query? Wrap them in a transaction? That
just slows down everyone else...

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________
 
Back
Top