PC Review


Reply
Thread Tools Rate Thread

how to determine whether a datarow is null or not

 
 
guoqi zheng
Guest
Posts: n/a
 
      29th Nov 2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?YmFsbWVyY2g=?=
Guest
Posts: n/a
 
      30th Nov 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
>

 
Reply With Quote
 
guoqi zheng
Guest
Posts: n/a
 
      30th Nov 2005
thanks, I think you are right about it..


regards,

Guoqi Zheng
http://www.ureader.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Deleting a DataRow from a DataTable results in null reference exception olrt Microsoft ADO .NET 9 8th Sep 2005 04:51 PM
Determine DataRow is Null ? URGENT Oney Microsoft ASP .NET 2 26th Nov 2004 01:29 PM
determine metadata for detached DataRow John A Grandy Microsoft ADO .NET 0 3rd Jul 2004 02:52 AM
setting field value in a DataRow to Null Nikhil Patel Microsoft ASP .NET 1 25th Mar 2004 04:18 PM
DataRow Find method returning null? Microsoft ADO .NET 2 25th Sep 2003 03:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:48 AM.