Parent and Child Binding any help is great

chrisguk

Active member
Joined
Nov 20, 2011
Messages
29
Programming Experience
Beginner
All I want is for my child detail to have unique records to each record in my parent detail. Please help?

Database is called: EMIDB


Dataset is called: EMIDBdataset.xsd


Within this dataset I have many tables with various primary and foreign keys.


The tables that I am talking about binding are as follows:


Table Name: Sites


Fields:


pkSitesID
Sitename
fkLocationName
fkStockNameID


My other table which has a relation is:


Table name: MeterProgram


Fields:


pkProgramMeterID
ProgramDetail
fkSitesID


The form:


Name: Sites.vb


I dragged in the designer the table from the dataset called tables in detail view to the form Sites.vb


I have the following adapters for this dataset: SitesBindingSource, SitesBindingNavigator and SitesTableAdapter


I then created a tab control and in page one I dragged in the designer view the table MeterProgram in.


This then created the following adapters: MeterProgramBindingSource and MeterProgramTableAdapter.


The parent = Sites


The Child = MeterProgram


In the properties of the SitesBindingSource it displays the following:


Datamember = Sites
DataSource = EMIDBdataset.xsd


In the Properties of MeterProgramBindingSource is displays the following:


Datamember = MeterProgram
DataSource = EMIDBDataset.xsd


I hit debug and the sites form is not displaying a one to many relationship with the fields from MeterProgram.


What have I done wrong.


Chris
 
Couple of points:
When Parent and Child are in a 1:1 relationship, consider putting temin the same table. I wouldnt have 2 tables: Names, Ages, each with: PersonID, Name. PersonID, Age.

In a standard Parent/Child relationshiop, any relations on the parent table, become available as data sources on the parent binding source:

ParentGridView->ParentBindingSource->ParentDataTable
ChildGridView->ChildBindingSource->ParentChildRelationName->ParentBindingSource

If you follow the DW4 link in my signature and read the Creating a Simple Data App tutorial you'll reach a point where it tells you to look in the Data Sources window and expand all the nodes (probably) where you will see that the child node is there twice.. once as its own at the root level, and once as a sub-node of the parent. If you drag the sub node onto your form you'll end up with:


In the properties of the SitesBindingSource it displays the following:


Datamember = Sites
DataSource = EMIDBdataset.xsd


In the Properties of MeterProgramBindingSource is displays the following:


Datamember = Sites_MeterProgram_DataRelation_Or_whatever_its_name_is
DataSource = SitesBindingSource
 
Back
Top