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

Posted on 2006-11-30
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
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

While MyReader.Read
End While
Catch ex as exception
'Code to handle the error caused by the empty datareader
End try
Question by:happyman14
  • 4
  • 3
LVL 10

Expert Comment

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

Author Comment

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

Author Comment

ID: 18046293
I did not want to use the error handling like a branching operation.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 10

Accepted Solution

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.

Author Comment

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.
LVL 10

Expert Comment

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

Author Comment

ID: 18046700
Thanks again

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now