Solved

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

Posted on 2006-11-30
7
517 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

12 Experts available now in Live!

Get 1:1 Help Now