happyman14
asked on
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
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
Looks like you'll have to settle with the error block, is the causing any issues ?
ASKER
I have not tried simply trapping the error. I thought there might be a better solution.
ASKER
I did not want to use the error handling like a branching operation.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks
Yes , there might be someone with another solution yet ;)
ASKER
Thanks again