I can loop while the datatable is full, but get an error when it is empty. How do I know it's empty.
Robert Walker
0
Newbie Poster
Recommended Answers
Jump to PostWhat is the error you are getting?
You could do a test for the number of records and only loop if it is greater than 0.
And how are you looping through the table?
Pseudo-Code:
Dim dr As OleDbDataReader = cmd.ExecuteReader() Do While dr.Read …
Jump to Post(For sake of confusion, I would not name my Dataset as myReader - seems to refer to a datareader to someone not knowing what you are coding for.... just some programming edicate I thought I should pass on)
Saying that......
Add the line
If myReader.Tables("dWeather").Rows.Count > 0 …
Jump to PostYou probably can guess this from the previous threads but I use:
dim MyTable as Datatable 'fill datatable.... If (MyTable Is Nothing) Or (MyTable.Rows.Count =0 ) Then 'it's empty Else 'it exists and there are rows End if
All 10 Replies
Paladine
138
Master Poster
Team Colleague
Robert Walker
0
Newbie Poster
Paladine
138
Master Poster
Team Colleague
ESHbyESH
0
Newbie Poster
janet_ss
-6
Newbie Poster
Comatose
290
Taboo Programmer
Team Colleague
Teme64
215
Veteran Poster
keith_mas
0
Newbie Poster
G_Waddell
131
Posting Whiz in Training
black_sun191
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.