Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sqlDataReader.read return true when no records 1

Status
Not open for further replies.

hkn

Programmer
Apr 30, 2001
6
DK
Hi

Normally I loop through records in a sqlDataReader by:

While MySqlDataReader.Read
...
End While

But in this case where there is no records in MySqlDataReader it is/returns true. When I debug I see it change from true to false and everything is fine. But when I build and run. The program returns with an error insight my while loop. When I debug and only have a break point insight the while loop, the program enter the while loop. I have tried to look at .HasRows, .IsDbNull and used temp. varialbles.

Does anybody have a solution?

Thanks Henrik
 
Henrik,
If you only want to know if any records exist in your criteria, please take a look at thread796-1142815.

Hope this helps.
 
Mansii

Thanks for the reply. No I need to loop through the records if any. But thank for the ExecuteScala idea, I did not think of that while trying to work around, good point.

The solution as it seems was:
At the same time I could not debug another added class project (question marks in the red break point dots). I removed the reference to the project (even though it seems ok) and inserted the reference to existing project exactly as it was before. Then I suddenly could debug in this class module and the sqlDataRead.Read worked as normally. That is the only thing I changed, just before things started working again.
The Visual Studio was in a bad state. It did not help to close VS, I tried that during my search for the problem.

Have a very good day, you never know when you run out.

Henrik
 
Henrik,
I'm sorry that my post did not find the point. Didn't know that it has something to do with another project.
It was wierd. Or perhaps, you should check the solution's configuration manager.

Anyways, good to know everything's back to normal. And thank's for the star.

Regards,
mansii
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top