A
Anand
Hi,
Was using DAO all along and following code was working fine:
wrkspc.Begintrans
with rst
..MoveFirst
Do Until .EOF
..AddNew
!pkID = DMax("pkID", "Table") +1
....other table fields
..Update
..MoveNext
Loop
End with
User Confirmation...
wrkspc.committrans
User Cancellation
wrkspc.rollback
Have recently switched to ADO - not much experience with it either...
Reworded the above code to make it suitable for ADO. Using connection object
to begin/commit/rollback the transaction.
Problem is that the code raises an error in ADO because the DMax function
(in ADO) gets the same pkID each time the loop executes - causing a primary
key integrity error. Have a feeling this is something to do with the way ADO
handles transactions - the first record is not added yet when in between a
begintrans and commit and causes DMax to get the same pkID. Any way out of
this?? Am I right in using connection object to process transactions?
TIA
Anand
Was using DAO all along and following code was working fine:
wrkspc.Begintrans
with rst
..MoveFirst
Do Until .EOF
..AddNew
!pkID = DMax("pkID", "Table") +1
....other table fields
..Update
..MoveNext
Loop
End with
User Confirmation...
wrkspc.committrans
User Cancellation
wrkspc.rollback
Have recently switched to ADO - not much experience with it either...
Reworded the above code to make it suitable for ADO. Using connection object
to begin/commit/rollback the transaction.
Problem is that the code raises an error in ADO because the DMax function
(in ADO) gets the same pkID each time the loop executes - causing a primary
key integrity error. Have a feeling this is something to do with the way ADO
handles transactions - the first record is not added yet when in between a
begintrans and commit and causes DMax to get the same pkID. Any way out of
this?? Am I right in using connection object to process transactions?
TIA
Anand