Solved

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

Posted on 2006-11-30
7
520 Views
Last Modified: 2011-04-14
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
0
Comment
Question by:happyman14
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 18046259
Looks like you'll have to settle with the error block, is the causing any issues ?
0
 

Author Comment

by:happyman14
ID: 18046272
I have not tried simply trapping the error. I thought there might be a better solution.
0
 

Author Comment

by:happyman14
ID: 18046293
I did not want to use the error handling like a branching operation.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
Kinger247 earned 500 total points
ID: 18046336
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
 

Author Comment

by:happyman14
ID: 18046462
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
 
LVL 10

Expert Comment

by:Kinger247
ID: 18046632
Yes , there might be someone with another solution yet ;)
0
 

Author Comment

by:happyman14
ID: 18046700
Thanks again
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question