473,508 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datatable.row.find method

I need a routine that runs through the current datatable to check for a
duplicate entry using two columns. When I set an array variable to object
and then set each variable's data to find, does the find method search for
var1 or var2, or var1 AND var2? I need it to include any rows that contain
both of these variables.

Here is code that I am using if it might help. If there is another way of
doing this, I am open to suggestions.

Thanks for the information.
Dim foundRow As DataRow

Dim findThese(1) As Object

findThese(0) = dtpEventDate.Value

If cmbShowTrial.SelectedText <> "" Then findThese(1) =
cmbShowTrial.SelectedText Else findThese(1) = ""

foundRow = DsConformation1.Tables(0).Rows.Find(findThese)

If Not (foundRow Is Nothing) Then 'row is found

MsgBox("This entry has already been made")

Exit Sub

End If
Nov 21 '05 #1
3 26625
Hi,

The find method will find a data row based on a primary key. The
primary key can be based on more than one column. If you set the primary key
equal to the 2 columns you will get an error if you try to add a duplicate
entry.

http://msdn.microsoft.com/library/de...rykeytopic.asp

http://msdn.microsoft.com/library/de...sFindTopic.asp

Ken
----------------------
"Brad" <al*******@sbcglobal.net> wrote in message
news:eZ****************@TK2MSFTNGP11.phx.gbl...
I need a routine that runs through the current datatable to check for a
duplicate entry using two columns. When I set an array variable to object
and then set each variable's data to find, does the find method search for
var1 or var2, or var1 AND var2? I need it to include any rows that contain
both of these variables.

Here is code that I am using if it might help. If there is another way of
doing this, I am open to suggestions.

Thanks for the information.
Dim foundRow As DataRow

Dim findThese(1) As Object

findThese(0) = dtpEventDate.Value

If cmbShowTrial.SelectedText <> "" Then findThese(1) =
cmbShowTrial.SelectedText Else findThese(1) = ""

foundRow = DsConformation1.Tables(0).Rows.Find(findThese)

If Not (foundRow Is Nothing) Then 'row is found

MsgBox("This entry has already been made")

Exit Sub

End If

Nov 21 '05 #2
Brad,

Bassed on your code I got this idea, why not use a dataview

When you do something the same as now and change every time the rowfilter,
based on your keys, than when the dataview.count is more than one you know
you have a duplicate.

It is just an idea I got when I was looking at your code so not tried.

I hope this helps?

Cor
Nov 21 '05 #3
Cor,

Thanks always for your help.

I did decide to use a dataview because as I discovered, the datarow.find
method only works on unique key columns. The criteria that I need to check
for are not unique columns. Using the dataview I search for the first
criteria and if found then I search for the second and if that is found then
I search for the third. If the final criteria is found then I know that
this is a duplicate entry, alerts the user and exits the sub.

Brad
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Brad,

Bassed on your code I got this idea, why not use a dataview

When you do something the same as now and change every time the rowfilter,
based on your keys, than when the dataview.count is more than one you know
you have a duplicate.

It is just an idea I got when I was looking at your code so not tried.

I hope this helps?

Cor

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2230
by: doug | last post by:
I would like to do a select distinct on a fieldname in a dataset. Is this possible using the DataTable.Select Method? If so do you have an example? I can use the method to do things like...
5
8019
by: harry | last post by:
Hi, Can the DataTable.Select Method use 'Distinct' to remove duplicate rows? If so how? I tried, however code triggered error 'no colmn 'Distinct' found'. Thanks Harry
1
3938
by: mirandacascade | last post by:
I do not understand how to use the find() method in ElementTree. The file 'sample.xml' is: <?xml version="1.0"?> <SampleRoot> <Header> <Product>FindMystery</Product> </Header>...
6
17419
by: Millo | last post by:
Hi I'm trying to call the method Contains in a loop: out of the loop I set the primary key of the dataTable. The method returns true one time at a certani value, but then, when the loop steps...
1
1631
by: Joe Smith | last post by:
Hello, Can we do SQL style SELECT queries in the DataTable.Select Method. e.g Filter String Expression = id < 5 AND (age <20 OR age >50) My goal is to be able to do advanced queries on a...
3
3674
by: emailtonitin | last post by:
Hi, I am having a problem with the default sorting mechanism employed by the datatable.select method - I have a datatable having rows (simplified for clarity) - name ----- c a
0
1189
by: njuneardave | last post by:
This line of code will make the Find method search for a search key in a given range if you search from top to bottom: m_form.richTextBox1.Find(searchKey, searchDownAreaStart, searchDownAreaEnd,...
2
24134
by: cameljs18 | last post by:
I have a datatable into which i insert data then display the data in a datagridview.When i want to clear the table and place completely new data in the table, the table still retains the column...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
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
7501
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
5633
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,...
1
5056
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
4713
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...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.