473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingSource.F ind 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("ColumnNa me", myColumnName)
If (index <-1) Then
myBindingSource .Position = index
End If

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

Thanks
Foef
Sep 28 '08 #1
1 12142
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.DataS ource, 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(filte r)
' auf Zeile positionieren
If rows.Length = 1 Then
Dim tempRows() As DataRow = dt.Select(bs1.F ilter, bs1.Sort)
bs1.Position = Array.IndexOf(t empRows, 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("ColumnNa me", myColumnName)
If (index <-1) Then
myBindingSource .Position = index
End If

How should I set the BindingSource.P osition 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
3363
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 the author id field. Or do I have to have many author id fields? Any way around that? Thanks, Bill *** Sent via Developersdex http://www.developersdex.com ***
3
2546
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 have access to using a single sql statement and it cannot be dynamic SQL or a stored procedure (this is a limitation based on the reporting tool we use). The conditions can be any combination of "and" and "or" operators. I have seen posts (and...
7
2459
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 table that has two keys and it seems you need this value to find the corresponding record in the DataSet in order to update the data from the Datagrid.
3
2552
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 the following error message . An unhandled exception of type 'System.InvalidCastException' occurred in system.data.dll Additional information: Specified cast is not valid.
1
3411
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 add a foreign key for this table linked to the 3 primary keys of table1 Can this be done /how? Any hint for that?
13
3770
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. Now, I wish to create a Classrooms (or something similar) table which will allow me to pick the Course from Courses and Instructors, and hold multiple Students for each Course. I am unsure how to do this in Access. Each student can have multiple...
1
4187
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: XXX34234234 DDD4324543
2
5268
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 keys. Initially I was using bindingsource.Position = datatable.DefaultView.Find(primaykey_objects) to position to the record but the method datatable.DefaultView.Find() returns the index of the record within the whole datatable and not within the...
2
4504
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 identify a customer. Then there is a details view that shows all their specifics. I wanted to keep navigation outside of my view. There is also a
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.