Forms for 1:1 Relationships

Thom1109

New member
Joined
Feb 10, 2006
Messages
3
Programming Experience
10+
I want to display fields from two database tables (tblMain and tblOptions) on a form and have one binding navigator. The tables I am showing are related 1:1 in my database.

To build my form, I am dragging and dropping controls from the data source window onto my form. I am starting with tblMain. This creates my tableAdapter and binding source object. It also creates the binding Navigator. This is easy enough and my form works perfectly.

The problem is after I add fields from tblOptions, my binding navigator does not work for the fields from tblOptions.
 
Ok, what you are talking about is a master/detail relationship between two tables. There are links set up between the two tables that establish a relationship and allow the navigation of the master table to effect the navigation of the detail table. You need to search for "master/detail" tables in this forum or use the links in jc's signature here: http://www.vbdotnetforums.com/member.php?find=lastposter&f=26
101 Samples is a good place to start.

The dataform wizard in vs2003 will create a form with master/detail relationship for you, it would be a good learning tool also.

Try that and see how far it gets you.
 
Thom1109 said:
I want to display fields from two database tables (tblMain and tblOptions) on a form and have one binding navigator. The tables I am showing are related 1:1 in my database.

To build my form, I am dragging and dropping controls from the data source window onto my form. I am starting with tblMain. This creates my tableAdapter and binding source object. It also creates the binding Navigator. This is easy enough and my form works perfectly.

The problem is after I add fields from tblOptions, my binding navigator does not work for the fields from tblOptions.

if they are 1:1, why are they in separate tables?

if you have a group of controls A and a group of controls B each with their own binding nav, and A:B is 1:1.. the dataset is loaded with 100 A and 100 B records, then A's nav (it is the driving nav) will be 1-100 scrollable.. B's nav however will only ever be 1-1 so it disables itself.

B cannot scroll A nor does it need to. At any one time there is only 1 record in B's datasource.. I think you have a database design flaw?
 
please also note: you have to manually load A and B - it is not enough to define a relationship from A to B in your dataset designer, then load A and hope that VB.NET will load B too.. no, you have to load both tables with data, and then the relation becomes a datasource. for a given record in A, the relation has X number of records from B. any controls bound to the relation as a data source show what records are present in the relation, which is a filtered subset of all of B
 
Back
Top