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

RE: how to determine whether a datarow is null or not by tristan49

tristan49
Wed Nov 30 12:03:11 CST 2005

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

"guoqi zheng" wrote:

> 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
>