Hi there. I have been trying to do this merge for a quite a while now and i think I am about to have enough. I have an access database that i want to connect to and want to merge a few columns from each record into another table with the same columns plus some more.
Eg. Table 1 fields: ID, aaa, bbb, ccc
Table 2 fields: ID, aaa, bbb, ccc, ddd, eee
Table 1 is the source table and table 2 is the new table that needs to have all fields from table 1 in it and then have the ability to add extra information into the other fields.
The code I have is as follows:
This brings back no errors and updates the datagrid with the existing table but I have a feeling I am VERY close to being correct.
Please help on this as I am at wits end.
Thankyou very much in advance
John G
Eg. Table 1 fields: ID, aaa, bbb, ccc
Table 2 fields: ID, aaa, bbb, ccc, ddd, eee
Table 1 is the source table and table 2 is the new table that needs to have all fields from table 1 in it and then have the ability to add extra information into the other fields.
The code I have is as follows:
VB.NET:
Dim conn As OleDbConnection = Me.DBConn
conn.Open()
Dim ds As New DataSet
Dim da As OleDbDataAdapter = New OleDbDataAdapter("select ID, aaa, bbb, ccc from tbl1", conn)
da.Fill(ds, "tbl1")
Dim ds2 As New DataSet
Dim da2 As OleDbDataAdapter = New OleDbDataAdapter("select ID, aaa, bbb, ccc from tbl2", conn)
da2.Fill(ds2, "tbl2")
ds2.Merge(ds) ', True, MissingSchemaAction.Add)
ds2.AcceptChanges()
ds.AcceptChanges()
conn.Close()
'fill datagrid
dg.DataSource() = ds
This brings back no errors and updates the datagrid with the existing table but I have a feeling I am VERY close to being correct.
Please help on this as I am at wits end.
Thankyou very much in advance
John G