No records retrived..?

K

Kent Johnson

Hi all,

I have the following:
==================
SQLSelect = "SELECT * from MyTable where Field1='" & strVar & "'"

Dim mySqlDA As New System.Data.SqlClient.SqlDataAdapter(SQLSelect, strConn)
Dim myDS As New System.Data.DataSet()

mySqlDA.Fill(myDS)
===================
...how can I handle the case if no records are retrived from the
SQL-statement?

/Kent J.
 
K

Kevin Spencer

..how can I handle the case if no records are retrived from the
SQL-statement?

What exactly do you mean? If no records are returned, your DataSet will have
no records in it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
K

Kent Johnson

Kevin,
Yes, that's what I mean.
I want to check the datset before proceeding.
Something like:

If isnull(myDS)=true then
Label1.Text="'What you asked for doesn't exist!"
exit sub
endif

/Kent J.
 
A

Alvin Bruney

I prefer
if(myDs != null && myDs.Tab....

since myDS can be null and the call to examine count will blow up. You knew
that but I wasn't sure others knew it.

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top