VB.NET Compact _How to check/handle an empty data reader?

In a VB.NET compact application I am using a data reader to retrieve data from a SQL Server Mobile db on the device.
If I use
While MyReader.read
and there is no data returned I get an error.
If I use
If MyReader.Read
     While MyReader.Read
and data is returned, the first row will be missing

The .NET Compact Framework does not support MyReader.HasRows.
What is the appropriate code to use for the data reader. Am I just trapping the error like

Try
While MyReader.Read
....
End While
Catch ex as exception
'Code to handle the error caused by the empty datareader
End try
happyman14Asked:
Who is Participating?
 
Kinger247Connect With a Mentor Commented:
I just tried it an get the same.
I don't see anything wrong in just trapping and moving on as a solution though.
0
 
Kinger247Commented:
Looks like you'll have to settle with the error block, is the causing any issues ?
0
 
happyman14Author Commented:
I have not tried simply trapping the error. I thought there might be a better solution.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
happyman14Author Commented:
I did not want to use the error handling like a branching operation.
0
 
happyman14Author Commented:
I Thank you for your speedy reply. I will try it.  I will leave the question open for a little while to see if there is another option, but I am thinking I will prpbably just trap the error.
Thanks
0
 
Kinger247Commented:
Yes , there might be someone with another solution yet ;)
0
 
happyman14Author Commented:
Thanks again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.