Consider the following:
I have two Access tables: TableA & TableB
TableA is a list of Names with a ZipID
TableB is a list of City, States, and Zips with a ZipID as a primary key
autonumbered
On a Windows Form I have two text boxes, Name (from TableA) and City (from
TableB)
I have the following code:
OleDbDataAdapte r nameAdapter = new OleDbDataAdapte r("SELECT
FirstName, ZipID from TableA", connection);
OleDbDataAdapte r zipAdapter = new OleDbDataAdapte r("SELECT ZipID,
City from TableB", connection);
DataSet completeDataSet = new DataSet();
nameAdapter.Fil l(completeDataS et, "TableA");
zipAdapter.Fill (completeDataSe t, "TableB");
DataRelation relation = completeDataSet .Relations.Add( "FullInfo",
completeDataSet .Tables["TableA"].Columns["ZipID"],
completeDataSet .Tables["TableB"].Columns["ZipID"],false);
bManager = this.BindingCon text[completeDataSet , "TableA"];
tbxParentField1 .DataBindings.A dd("Text", completeDataSet ,
"TableA.FirstNa me");
tbxChildField1. DataBindings.Ad d("Text", completeDataSet ,"TableB.City") ;
I have Next and Previous buttons on the form, with:
bManager.Positi on += 1; & bManager.Positi on -= 1; respectively
The form works fine for displaying the FirstName (tbxParentField 1) and
scrolling through the records, but the City does not move (tbxChildField1 ). I
just can't figure out what I am missing when binding the TableB.City field so
that it updates based on the selected FirstName.
Any help would be greatly appreciated.
thanks,
mitch
I have two Access tables: TableA & TableB
TableA is a list of Names with a ZipID
TableB is a list of City, States, and Zips with a ZipID as a primary key
autonumbered
On a Windows Form I have two text boxes, Name (from TableA) and City (from
TableB)
I have the following code:
OleDbDataAdapte r nameAdapter = new OleDbDataAdapte r("SELECT
FirstName, ZipID from TableA", connection);
OleDbDataAdapte r zipAdapter = new OleDbDataAdapte r("SELECT ZipID,
City from TableB", connection);
DataSet completeDataSet = new DataSet();
nameAdapter.Fil l(completeDataS et, "TableA");
zipAdapter.Fill (completeDataSe t, "TableB");
DataRelation relation = completeDataSet .Relations.Add( "FullInfo",
completeDataSet .Tables["TableA"].Columns["ZipID"],
completeDataSet .Tables["TableB"].Columns["ZipID"],false);
bManager = this.BindingCon text[completeDataSet , "TableA"];
tbxParentField1 .DataBindings.A dd("Text", completeDataSet ,
"TableA.FirstNa me");
tbxChildField1. DataBindings.Ad d("Text", completeDataSet ,"TableB.City") ;
I have Next and Previous buttons on the form, with:
bManager.Positi on += 1; & bManager.Positi on -= 1; respectively
The form works fine for displaying the FirstName (tbxParentField 1) and
scrolling through the records, but the City does not move (tbxChildField1 ). I
just can't figure out what I am missing when binding the TableB.City field so
that it updates based on the selected FirstName.
Any help would be greatly appreciated.
thanks,
mitch
Comment