how to determine whether a datarow is null or not

G

guoqi zheng

Dear sir,

I am trying to find a row in a dataset. I know I can define a primaryKey and
use rows.find(key) to locate this row.

However, very often this row does not exists, what can I use to determine
whether this row exists or not??
Dim objSet As New DataSet
objSet.ReadXmlSchema("e:\abc\test.xsd")
objSet.ReadXml("e:\abc\test.xml")
objSet.Tables(0).PrimaryKey = New DataColumn() {objSet.Tables(0). Columns("GroupId")}
Dim datarow As DataRow = objSet.Tables(0).Rows.Find(9)

Now I need to determine whether it finds the row with key=9 or not? How can
I do it?

regards,

Guoqi Zheng
http://www.ureader.com
 
G

Guest

I haven't used vb.net in a while but I believe it was:

If datarow is nothing Then
'do stuff for null
Else
'do stuff for exist
End If

or if you just want to do stuff when it exists:

If not datarow is nothing Then
'do something
End If

Chris
 

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

Top