473,418 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

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 2442
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
4
by: shaun palmer | last post by:
when or Where do you use a union query ? how can I wright sql, tblPopulation,* tblcustomer,* one to one with all the appropriate attributes(field). Your help would be greatly...
9
by: Frederik | last post by:
Hi all, I'm building a C# application that uses a M$ Acces database. In one of the queries I use something like the following: SELECT id FROM mytable WHERE id IN (20, 12, 21, 14) The result...
6
by: MLH | last post by:
If I cut it from the rest of the SQL, the query runs fine. But when I leave the following WHERE clause in there, Access tells me there's a missing Operator? WHERE (((tblVehicleJobs.SerialNum)...
6
by: Altman | last post by:
I am playing around with making a dataset with the designer in vb.net 2005. I realize you can add parameters to select statement and then filter off of those parameters. What I would like to do...
1
by: not_a_commie | last post by:
I was hoping for increased functionality with the where clause in C# 3.0. Using the new keyword 'var' would really allow us to take nice advantage of these. Specifically: 1. I want to limit it...
5
by: pwiegers | last post by:
Hi, I'm trying to use the result of a conditional statement in a where clause, but i'm getting 1)nowhere 2) desperate :-) The query is simple: -------- SELECT idUser,...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Is it possible to use a wildcard like feature with Dataview.Find? Actually, I tried that but did not get any rows. Is there some wildcard like feature of the dataview or some other object that I...
3
by: Steven Edison | last post by:
I'm sure this will be a simple one... I have a SqlDataSource that I need a WHERE clause on it ONLY when the querystring contains "ProjectID", otherwise I don't need it. If you come to the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.