I was hoping to populate an OracleDataTable, set the RowState of all the rows to Added, change the connection of the OracleDataTable to point at the destination database and then call .Update() on the datatable. However there are two problems, one is that the row Rowstate property is readonly, the other is that it seems that even if you change the connection of the OracleDataTable and then call update, it still seems to want to update back to the original database.
I thought of something like this, which solves the first point but not the second:
Code: Select all
Dim cmd As New OracleCommand
Dim dtSource As OracleDataTable
Dim row As DataRow
Dim dtDest As OracleDataTable
cmd.CommandText = "TABLE"
cmd.CommandType = CommandType.TableDirect
cmd.Connection = connSource
dtSource = New OracleDataTable(cmd)
dtSource.Active = True
dtDest = New OracleDataTable
dtDest = dtSource.Clone
dtDest.Clear()
dtDest.AcceptChanges()
For Each row In dtSource.Rows
dtDest.Rows.Add(row.ItemArray)
Next
dtDest.Connection = connDest
dtDest.Update()
Any suggestions?
Thanks