473,327 Members | 1,976 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,327 software developers and data experts.

BindingSource.Find with multiple primary keys

I have a BindingSource with an underlying table with two primary keys.

To set the position with one primary key works fine as shown in the code
snippet below:
Dim index As Integer = myBindingSource.Find("ColumnName", myColumnName)
If (index <-1) Then
myBindingSource.Position = index
End If

How should I set the BindingSource.Position with two or more primary keys?

Thanks
Foef
Sep 28 '08 #1
1 12077
Found it at the German Newsgroup:

Dim par1 As Integer = 5
Dim par2 As Integer = 6
' Verweis auf Tabelle
Dim dt As DataTable = _
CType(bs1.DataSource, DataSet).Tables(bs1.DataMember)
' Filter aufbauen
Dim filter As String = _
String.Format("{0} = {1} AND {2} = {3}", _
dt.PrimaryKey(0).ColumnName, par1, _
dt.PrimaryKey(1).ColumnName, par2)
' DataRow heraussuchen
Dim rows() As DataRow = dt.Select(filter)
' auf Zeile positionieren
If rows.Length = 1 Then
Dim tempRows() As DataRow = dt.Select(bs1.Filter, bs1.Sort)
bs1.Position = Array.IndexOf(tempRows, rows(0))
Else
Trace.WriteLine("kein Satz gefunden")
End If
"Foef" wrote:
I have a BindingSource with an underlying table with two primary keys.

To set the position with one primary key works fine as shown in the code
snippet below:
Dim index As Integer = myBindingSource.Find("ColumnName", myColumnName)
If (index <-1) Then
myBindingSource.Position = index
End If

How should I set the BindingSource.Position with two or more primary keys?

Thanks
Foef
Sep 29 '08 #2

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

Similar topics

5
by: Bill | last post by:
I have a book cataloge where I have an author id linked up to the book. However, I'm finding that some books have mulitple authors, and I'm wondering if there is a way to add more than one id to...
3
by: gregory.sharrow | last post by:
I need to secure a datawarehouse table at the row level based on 1 to many keys on that table. A user should only see the rows they have access to. I need to be able to figure out which rows they...
7
by: Dave | last post by:
Hi, Maybe I'm missing something with the DataKeyField attribute of a datagrid but it seems that it's somewhat limiting since this only allows you to specify one field as the key. I have a...
3
by: rnettle | last post by:
Can anyone tell me how to use the DataRowCollection.Find Method on 3 primary keys, 2 of the keys are of the String type and the other is of the DateTime type. I have tried the code below but get...
1
by: CharChabil | last post by:
Hey guys Using Sql/express Table 1 : I set 3 fields to be primary keys for Table1 (i have just marked each field with a key (primary key)(is there anything else to do)? Table 2 : I should...
13
by: Eric IsWhoIAm | last post by:
I have four tables created so far: Courses, Instructors, Courses and Instructors (which shows the Course and Instructor Name fields, but holds their IDs since those are the keys), and Students....
1
by: Alexander Loose | last post by:
Hello, I am using the BindingSource.Find-Methode to find an Item in my BindingSource. This works fine to find the exact pattern, but now I search for a fuzzy finding method. For example: ...
2
by: NicSM | last post by:
Hi Can anyone please help me with this problem? I'm working with a master/detail windows form in c# and I'm trying to locate a record in the detail section with respect to a set of primary...
2
by: jehugaleahsa | last post by:
Hello: I'm working on improving some of our Windows Forms. I have created two user controls that I want to bind to the same BindingSource. I have an overview control that is used just to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.