Golf
Member
- Joined
- Jan 25, 2006
- Messages
- 5
- Programming Experience
- Beginner
The code below copy SQL result from ORACLE database to ACCESS database
at the first time but other times duplicate data , when i assign key to the Target table , the compiler give a error message
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again "
at the first time but other times duplicate data , when i assign key to the Target table , the compiler give a error message
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again "
VB.NET:
Dim cnOra As OracleConnection = New OracleConnection("Data Source=prod;User Id=xxx;Password=xxx;")
Dim cnAccess As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\xxx1.mdb;User Id=admin;Password=;")
Dim da1 As OracleDataAdapter, dt As DataTable, cmd As OleDbCommandBuilder
Dim da2 As OleDbDataAdapter
da1 = New OracleDataAdapter("Select * FRom abc", cnOra)
da1.AcceptChangesDuringFill = False
dt = New DataTable
da1.Fill(dt)
da1.Dispose()
If Not dt Is Nothing Then
da2 = New OleDbDataAdapter("SELECT * FROM xyz", cnAccess)
cmd = New OleDbCommandBuilder(da2)
da2.InsertCommand = cmd.GetInsertCommand
da2.Update(dt)
da2.Dispose()
cmd.Dispose()
dt.Dispose()
End If