Populating a form with data from different tables.
Posted on 2004-08-04
I have a form which needs to contain data from two different tables. The tables have a one to many relationship. Currently I have filled the dataset with both tables and created the appropriate relationship between the two tables, but I need to know how to make the linked records display on the form at the same time. Right now they do not. Here is the code I have now:
Dim da_table1 As New OleDb.OleDbDataAdapter("SELECT * FROM table1", Conn)
Dim da_table2 As New OleDb.OleDbDataAdapter("Select * From table2", Conn)
Dim childCol As DataColumn = ds.Tables("table1").Columns("column1")
Dim parentCol As DataColumn = ds.Tables("table2").Columns("column2")
Dim relMPSMS As DataRelation
relMPSMS = New DataRelation("rel", parentCol, childCol)
' Add the relation to the DataSet.
TextBox1.DataBindings.Add("Text", ds, "table1.column1")
TextBox9.DataBindings.Add("Text", ds, "table2.column2")
TextBox7.DataBindings.Add("Text", ds, "table2.column3")
I am new to VB.Net and ADO.Net so explanations with code would be helpful, Thanks