Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cancelupdate not working on after ADDNEW

5 views
Skip to first unread message

Yitzak

unread,
May 10, 2007, 6:36:36 AM5/10/07
to
Hi
I'm Using ADO with a bound control in VB6.
I'm deliberately creating an error by trying to add some thing that
breaks a unique constraint

on error goto errh
oRS.addnew
oRs.fields("id") = 2 ' this will error later on
oRs.update
exit sub
errh
msgbox err.description
oRs.cancelupdate


When I try editing an existing record and set ID =2 it generates an
error -Cannot insert duplicate key row in object 'TABLE' with unique
index 'CK_#########'.
I then run oRS.cancelupdate and the ID value changes back to what it
was..

If however I'm adding a new record and try cancelupdate after the
attempted update method fails. I get
"Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done."

BUT the record is still in the recordset. I cannot requery or close
the recorset only way around it is to set oRS = new adodb.recordset
and redo query.

Errors
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert duplicate
key row in object 'TABLE' with unique index 'CK_#########'.
[Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been
terminated.
[Microsoft][ODBC SQL Server Driver]Invalid cursor position
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.

Then after calling cancelupdate.
Operation was canceled.
1

Yitzak

unread,
May 10, 2007, 6:52:24 AM5/10/07
to
Damm!!!

Sorry realised after posting I was using ODBC - rather than OLEDB...

0 new messages