G
Guest
I am attempting to select data from Database A into Database B (both Access
Databases) by placing the selected data into a Dataset and then inserting it
into the 2nd DB. I can select the data, fill the dataset, create the Adapter
commands for insert update delete, but the update is not successful. Here's
the code:
'g_strConnectionString = Connectionstring to Database A (original DB)
strSQL = "Select * from tblCase where CaseID = " & (Me.CaseID)
Dim objDbCommandAdapter2 As New OleDbDataAdapter(strSQL,
g_strConnectionString)
objDbCommandAdapter2.AcceptChangesDuringFill = False
objDbCommandAdapter2.Fill(objDataSet)
'm_strConnectionString = ConnectionString to Database B (destination DB)
Dim objDbCommandAdapter As New OleDbDataAdapter("Select * from tblCase",
m_strConnectionString)
Dim objDbCommandBuilder As New OleDbCommandBuilder(objDbCommandAdapter)
Try
objDbCommandAdapter.InsertCommand =
objDbCommandBuilder.GetInsertCommand()
objDbCommandAdapter.InsertCommand.Connection = objConn
objDbCommandAdapter.UpdateCommand =
objDbCommandBuilder.GetUpdateCommand()
objDbCommandAdapter.UpdateCommand.Connection = objConn
objDbCommandAdapter.DeleteCommand =
objDbCommandBuilder.GetDeleteCommand()
objDbCommandAdapter.DeleteCommand.Connection = objConn
Dim DSChanges As New DataSet
DSChanges = objDataSet.GetChanges()
intRetval = objDbCommandAdapter.Update(DSChanges, "tblCase")
The error I receive is "Update unable to find TableMapping['tblCase'] or
DataTable 'tblCase'." The table structure does exist in the destination DB
and I thought the Select from DestinationDB provided the structure to the
Adapter.
Please help. Thanks.
Databases) by placing the selected data into a Dataset and then inserting it
into the 2nd DB. I can select the data, fill the dataset, create the Adapter
commands for insert update delete, but the update is not successful. Here's
the code:
'g_strConnectionString = Connectionstring to Database A (original DB)
strSQL = "Select * from tblCase where CaseID = " & (Me.CaseID)
Dim objDbCommandAdapter2 As New OleDbDataAdapter(strSQL,
g_strConnectionString)
objDbCommandAdapter2.AcceptChangesDuringFill = False
objDbCommandAdapter2.Fill(objDataSet)
'm_strConnectionString = ConnectionString to Database B (destination DB)
Dim objDbCommandAdapter As New OleDbDataAdapter("Select * from tblCase",
m_strConnectionString)
Dim objDbCommandBuilder As New OleDbCommandBuilder(objDbCommandAdapter)
Try
objDbCommandAdapter.InsertCommand =
objDbCommandBuilder.GetInsertCommand()
objDbCommandAdapter.InsertCommand.Connection = objConn
objDbCommandAdapter.UpdateCommand =
objDbCommandBuilder.GetUpdateCommand()
objDbCommandAdapter.UpdateCommand.Connection = objConn
objDbCommandAdapter.DeleteCommand =
objDbCommandBuilder.GetDeleteCommand()
objDbCommandAdapter.DeleteCommand.Connection = objConn
Dim DSChanges As New DataSet
DSChanges = objDataSet.GetChanges()
intRetval = objDbCommandAdapter.Update(DSChanges, "tblCase")
The error I receive is "Update unable to find TableMapping['tblCase'] or
DataTable 'tblCase'." The table structure does exist in the destination DB
and I thought the Select from DestinationDB provided the structure to the
Adapter.
Please help. Thanks.