I have two Access databases: one has records, the other only has blank
tables. I want to copy records to the empty database. I am using a
DataAdaptor and a DataSet for the transfer. My code works for for editing
records or using the Row.ADD() method to append records.
To transfer the records, I have tried the code shown below and variations of
it. The code does not cause an exception but does not transfer the records
either. What code structure should I use for this task?
Dim sSQL As String = "Select * From Publishers"
Dim oleConnLoad As New
OleDb.OleDbConnection(gsConnectionStringLoad)
Dim oleConnSave As New
OleDb.OleDbConnection(gsConnectionStringSave)
Dim oleDALoad As New OleDb.OleDbDataAdapter(sSQL, oleConnLoad)
Dim oleDASave As New OleDb.OleDbDataAdapter(sSQL, oleConnSave)
Dim oDSLoad As New DataSet
Dim oDSSave As New DataSet
oleDALoad.Fill(oDSLoad, "Publishers")
oleDASave.Fill(oDSSave, "Publishers")
Dim oCmdBuilder As New OleDb.OleDbCommandBuilder(oleDASave)
oCmdBuilder.QuotePrefix = "["
oCmdBuilder.QuoteSuffix = "]"
oleDASave.InsertCommand = oCmdBuilder.GetInsertCommand
oleDASave.DeleteCommand = oCmdBuilder.GetDeleteCommand
oleDASave.UpdateCommand = oCmdBuilder.GetUpdateCommand
oDSSave.Merge(oDSLoad)
oleDASave.Update(oDSSave, "Publishers")