PC Review


Reply
Thread Tools Rate Thread

where clause or something similar for dataview.find?

 
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      5th Feb 2007
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
 
Reply With Quote
 
 
 
 
RobinS
Guest
Posts: n/a
 
      6th Feb 2007
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" <(E-Mail Removed)> wrote in message
news:F4911BDC-DAF5-42CC-B93F-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      6th Feb 2007
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" <(E-Mail Removed)> wrote in message
> news:F4911BDC-DAF5-42CC-B93F-(E-Mail Removed)...
> > 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

>
>
>

 
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
to find the data from one dataview not in another dataview joe Microsoft ADO .NET 0 9th Jul 2008 10:39 AM
Change the layout of a DataView (or similar control) - i.e. accrossnot down JB Microsoft C# .NET 1 27th May 2008 04:32 PM
Find row using * wildcard or similar (Like) with dataview/dataTabl =?Utf-8?B?UmljaA==?= Microsoft VB .NET 4 9th Mar 2007 05:54 AM
adding items to listbox with extra data similar to databinding to dataview TS Microsoft Dot NET Framework Forms 2 16th Feb 2005 03:26 AM
Mismatch between dataview rowfilter and oracle where clause results Sriram Microsoft ADO .NET 3 2nd Dec 2003 01:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:25 AM.