470,628 Members | 2,294 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,628 developers. It's quick & easy.

where clause or something similar for dataview.find?

Greetings,

I need to locate a row (or see if it exists) in a table contained in a
dataset. The DataView.Find method seems to work OK for one criteria but I
need to use 2 criterias. Is there anything in VB2005 that does was DLookUpd
does in Access - but for a table contained in a Dataset? I realize that
DLookUp works on Physical tables (not in-memory dataset tables), and I could
use a sqlDataReader to find my row from the physical table. But I am hoping
there is a way to find this row in the dataTable of the data that I have
already pulled (Ideally without having to loop through each row - althought,
that is my alternative).

Thanks,
Rich
Feb 5 '07 #1
2 2336
From Dave Sceppa's ADO.Net Core Reference. I kind of merged info from a
couple of different places together. Hope it leads you in the right
direction.

The Find method is overloaded in case you have multiple columns in your
primary key.You can specify a single value or an array of values. It
returns an integer value that corresponds to the index of the desired row
in the DataView. If can't find it, it returns -1.

Dim dv as New DataView(dt) 'dt is Customers table
Dim Index As Integer = dv.Find("Fran Wilson")
If Index = -1 Then
'not found
Else
Console.WriteLine(dv(Index)("CompanyName"))
End If

This is how he shows doing it with multiple columns against a datatable, to
get a set of rows. I think the methodology for using the array would be the
same for a dataview.

dt.PrimaryKey = New DataColumn() {dt.Columns("OrderID"),
dt.Columns("ProductID")}
Dim objCriteria As New Object() {10643, 28}
Dim row As DataRow = dt.Rows.Find(objCriteria)

He ties sorting and Find together in his book.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
----------------------------------------------------------
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.com...
Greetings,

I need to locate a row (or see if it exists) in a table contained in a
dataset. The DataView.Find method seems to work OK for one criteria but
I
need to use 2 criterias. Is there anything in VB2005 that does was
DLookUpd
does in Access - but for a table contained in a Dataset? I realize that
DLookUp works on Physical tables (not in-memory dataset tables), and I
could
use a sqlDataReader to find my row from the physical table. But I am
hoping
there is a way to find this row in the dataTable of the data that I have
already pulled (Ideally without having to loop through each row -
althought,
that is my alternative).

Thanks,
Rich

Feb 6 '07 #2
Thanks for your reply. It looks like good information. Close of business
day now, so I will try it out in the morning.

Thanks,
Rich

"RobinS" wrote:
From Dave Sceppa's ADO.Net Core Reference. I kind of merged info from a
couple of different places together. Hope it leads you in the right
direction.

The Find method is overloaded in case you have multiple columns in your
primary key.You can specify a single value or an array of values. It
returns an integer value that corresponds to the index of the desired row
in the DataView. If can't find it, it returns -1.

Dim dv as New DataView(dt) 'dt is Customers table
Dim Index As Integer = dv.Find("Fran Wilson")
If Index = -1 Then
'not found
Else
Console.WriteLine(dv(Index)("CompanyName"))
End If

This is how he shows doing it with multiple columns against a datatable, to
get a set of rows. I think the methodology for using the array would be the
same for a dataview.

dt.PrimaryKey = New DataColumn() {dt.Columns("OrderID"),
dt.Columns("ProductID")}
Dim objCriteria As New Object() {10643, 28}
Dim row As DataRow = dt.Rows.Find(objCriteria)

He ties sorting and Find together in his book.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
----------------------------------------------------------
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.com...
Greetings,

I need to locate a row (or see if it exists) in a table contained in a
dataset. The DataView.Find method seems to work OK for one criteria but
I
need to use 2 criterias. Is there anything in VB2005 that does was
DLookUpd
does in Access - but for a table contained in a Dataset? I realize that
DLookUp works on Physical tables (not in-memory dataset tables), and I
could
use a sqlDataReader to find my row from the physical table. But I am
hoping
there is a way to find this row in the dataTable of the data that I have
already pulled (Ideally without having to loop through each row -
althought,
that is my alternative).

Thanks,
Rich


Feb 6 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

47 posts views Thread by Andrey Tatarinov | last post: by
9 posts views Thread by Frederik | last post: by
6 posts views Thread by Altman | last post: by
1 post views Thread by not_a_commie | last post: by
5 posts views Thread by pwiegers | last post: by
3 posts views Thread by Steven Edison | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.