By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,325 Members | 1,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,325 IT Pros & Developers. It's quick & easy.

where clause or something similar for dataview.find?

P: n/a
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
Share this Question
Share on Google+
2 Replies

P: n/a
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

P: n/a
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.