Question Combine data from two table (Access)

lhdvbnet

Member
Joined
Feb 25, 2009
Messages
15
Programming Experience
Beginner
My Problem: i have 01 data table (A) in MS Access, my group have 2 members, we input data into table A seperately => A1, A2. Now, we want to combine data in two tables (A1, A2) into unique table (A) by code in VB.NET. :(

I have no idea to resolve this problem. :confused:

Someone help me! :rolleyes:

Thank in advanced :)

(SORRY ABOUT MY ENGLISH)
 
You should find that this will work, although I haven't tested it:
VB.NET:
Dim connection1 As New OleDbConnection("database1 connection string here")
Dim connection2 As New OleDbConnection("database2 connection string here")
Dim adapter As New OleDbDataAdapter("SELECT * FROM MyTable", connection1)

'Keep all RowStates as Added so rows are ready to be inserted.
adapter.AcceptChangesDuringFill = False

adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

Dim table As New DataTable

'Get the data from the first database.
adapter.Fill(table)

Dim builder As New OleDbCommandBuilder(adapter)
Dim command As OleDbCommand = builder.GetInsertCommand()

'Connect to the second database instead of the first for saving.
command.Connection = connection2
adapter.InsertCommand = command

'Save the data to the second database.
adapter.Update(table)
 
If youre saying that you have two tables inside one database file:


SELECT INTO tableA * FROM(
SELECT * FROM a1
UNION
SELECT * FROM A2
)
 

Latest posts

Back
Top