OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Table_1", conn);
da.Fill(ds, "Table_1");
da = new OleDbDataAdapter("SELECT * FROM Table_2", conn);
da.Fill(ds, "Table_2");
da = new OleDbDataAdapter("SELECT * FROM Table_3", conn);
da.Fill(ds, "Table_3");
DataColumn masterOne = ds.Tables["Table_1"].Columns["tableOneID"];
DataColumn childOne = ds.Tables["Table_2"].Columns["tableOneID"];
DataRelation relation = new DataRelation("RelationMasterChild", masterOne, childOne);
ds.Relations.Add(relation);
cboTable_1.DataSource = ds;
cboTable_1.DisplayMember = "Table_1.displayString";
cboTable_1.ValueMember = "Table_1.tableOneID";
cboTable_2.Datasource = ds;
cboTable_2.DisplayMember = "Table_1.RelationMasterChild.displayString";
cboTable_2.ValueMember = "Table_1.RelationMasterChild.tableTwoID";
// Now I would assume that I can connect tables 2 and 3 in the same way
DataColumn masterTwo = ds.Tables["Table_2"].Columns["tableTwoID"];
DataColumn childTwo = ds.Tables["Table_3"].Columns["tableTwoID"];
relation = new DataRelation("RelationChildChild", masterTwo, childTwo);
ds.Relations.Add(relation);
cboTable_3.Datasource = ds;
cboTable_3.DisplayMember = "Table_2.RelationChildChild.displayString";
cboTable_3.ValueMember = "Table_2.RelationChildChild.tableThreeID";
Enter your message below
Sign in or Join us (it's free).