G
Guest
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:
OleDbDataAdapter nameAdapter = new OleDbDataAdapter("SELECT
FirstName, ZipID from TableA", connection);
OleDbDataAdapter zipAdapter = new OleDbDataAdapter("SELECT ZipID,
City from TableB", connection);
DataSet completeDataSet = new DataSet();
nameAdapter.Fill(completeDataSet, "TableA");
zipAdapter.Fill(completeDataSet, "TableB");
DataRelation relation = completeDataSet.Relations.Add("FullInfo",
completeDataSet.Tables["TableA"].Columns["ZipID"],
completeDataSet.Tables["TableB"].Columns["ZipID"],false);
bManager = this.BindingContext[completeDataSet, "TableA"];
tbxParentField1.DataBindings.Add("Text", completeDataSet,
"TableA.FirstName");
tbxChildField1.DataBindings.Add("Text", completeDataSet,"TableB.City");
I have Next and Previous buttons on the form, with:
bManager.Position += 1; & bManager.Position -= 1; respectively
The form works fine for displaying the FirstName (tbxParentField1) 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:
OleDbDataAdapter nameAdapter = new OleDbDataAdapter("SELECT
FirstName, ZipID from TableA", connection);
OleDbDataAdapter zipAdapter = new OleDbDataAdapter("SELECT ZipID,
City from TableB", connection);
DataSet completeDataSet = new DataSet();
nameAdapter.Fill(completeDataSet, "TableA");
zipAdapter.Fill(completeDataSet, "TableB");
DataRelation relation = completeDataSet.Relations.Add("FullInfo",
completeDataSet.Tables["TableA"].Columns["ZipID"],
completeDataSet.Tables["TableB"].Columns["ZipID"],false);
bManager = this.BindingContext[completeDataSet, "TableA"];
tbxParentField1.DataBindings.Add("Text", completeDataSet,
"TableA.FirstName");
tbxChildField1.DataBindings.Add("Text", completeDataSet,"TableB.City");
I have Next and Previous buttons on the form, with:
bManager.Position += 1; & bManager.Position -= 1; respectively
The form works fine for displaying the FirstName (tbxParentField1) 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