K
klaas
Guest
Hi,
we have had a strange error when trying to use ADO for transferring data from one database called DBcheck (without relations and primary keys) to another of identical structure called DBfinal (but with relations and primary keys). When using the code pasted below, everything works fine until we are trying to insert a record into DBfinal that lacks a corresponding entry in a hierarchically higher table. We receive an error message saying that the data could not be appended to the table because the defined relations demand that there should be a corresponding entry in another table (error number -2147217887).
We knew that these constellations would occur, thus an error handling routine copes with this situation. The problem is that once this error has been handled, the same error occurs with *each* following attempt to transfer data from DBcheck to DBfinal - even though all necessary entries in hierarchically higher tables exist. Furthermore, the recordset that we are *reading* the data from in DBcheck can no longer be closed.
If we try to insert the concerned data manually into DBfinal, everything works fine. Does anyone have any suggestion about the cause of these problems and how to solve them?
We attach the essential parts of the code (which has been tested with different ADO libraries, ranging from version 2.1 to 2.7 - all give the same problem).
We desperately need to get this code working - any help would be highly appreciated!
Klaas & Konrad
...
cnnDBcheck.ConnectionString = "Data Source=" & outputPath & "\" &
DBcheckName & ";Provider=Microsoft.Jet.OLEDB.4.0"
cnnDBfinal.ConnectionString = "Data Source=" & outputPath & "\" &
DBfinalName & ";Provider=Microsoft.Jet.OLEDB.4.0"
...
rstDBcheck.Open strTableName, cnnDBcheck, adOpenKeyset,
adLockOptimistic, adCmdTableDirect
rstDBfinal.Open strTableName, cnnDBfinal, adOpenDynamic,
adLockOptimistic, adCmdTableDirect
...
rstDBcheck.MoveFirst
Do Until rstDBcheck.EOF
If rstDBcheck!CompCode <> 3 Then
varTMP = rstDBcheck.GetRows(1, Fields:=arrFields) 'Copying
Current Record to an array, get rows does a move next
arrRecord = rearangeArray(varTMP) ' convert an 2D Array with
one line to an 1D array
rstDBfinal.AddNew arrFields, arrRecord ' !!! the error occurs after this statement !!!
rstDBfinal.Update
Else
rstDBcheck.MoveNext
End If
Loop
...
we have had a strange error when trying to use ADO for transferring data from one database called DBcheck (without relations and primary keys) to another of identical structure called DBfinal (but with relations and primary keys). When using the code pasted below, everything works fine until we are trying to insert a record into DBfinal that lacks a corresponding entry in a hierarchically higher table. We receive an error message saying that the data could not be appended to the table because the defined relations demand that there should be a corresponding entry in another table (error number -2147217887).
We knew that these constellations would occur, thus an error handling routine copes with this situation. The problem is that once this error has been handled, the same error occurs with *each* following attempt to transfer data from DBcheck to DBfinal - even though all necessary entries in hierarchically higher tables exist. Furthermore, the recordset that we are *reading* the data from in DBcheck can no longer be closed.
If we try to insert the concerned data manually into DBfinal, everything works fine. Does anyone have any suggestion about the cause of these problems and how to solve them?
We attach the essential parts of the code (which has been tested with different ADO libraries, ranging from version 2.1 to 2.7 - all give the same problem).
We desperately need to get this code working - any help would be highly appreciated!
Klaas & Konrad
...
cnnDBcheck.ConnectionString = "Data Source=" & outputPath & "\" &
DBcheckName & ";Provider=Microsoft.Jet.OLEDB.4.0"
cnnDBfinal.ConnectionString = "Data Source=" & outputPath & "\" &
DBfinalName & ";Provider=Microsoft.Jet.OLEDB.4.0"
...
rstDBcheck.Open strTableName, cnnDBcheck, adOpenKeyset,
adLockOptimistic, adCmdTableDirect
rstDBfinal.Open strTableName, cnnDBfinal, adOpenDynamic,
adLockOptimistic, adCmdTableDirect
...
rstDBcheck.MoveFirst
Do Until rstDBcheck.EOF
If rstDBcheck!CompCode <> 3 Then
varTMP = rstDBcheck.GetRows(1, Fields:=arrFields) 'Copying
Current Record to an array, get rows does a move next
arrRecord = rearangeArray(varTMP) ' convert an 2D Array with
one line to an 1D array
rstDBfinal.AddNew arrFields, arrRecord ' !!! the error occurs after this statement !!!
rstDBfinal.Update
Else
rstDBcheck.MoveNext
End If
Loop
...