Solved

Rollback using ADO.Recordset!

Posted on 2002-04-15
6
302 Views
Last Modified: 2008-03-06
Hi,

I use ADO to add/update/delete record to my Oracle DB.

In using a recrodset's method --> AddNew, Update.

Do I need to do a rollback if the AddNew, Update fails?

If yes, how can I do this?

I found there exists a rollback method at the conneciton object, but not at recordset object.

My table at oralce db contains a field which is of type BLOB.

I only know how to use the recordset object to add record to this table which will add a binary file to the database.

In my case, how can I do a rollback if the operation fails?


Thanks for your advice!
0
Comment
Question by:DoraMeMe
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
DoraMeMe: You need to use the following methodology to incorporate rollback/commit process. It is effectively the same as the transaction control methods you would apply in your oracle stored procedures or scripts just implemented through ADO.

- Pseudo-code :

Connection.BeginTrans
Recordset.ProcessData
If Connection.Errors.Count > 0 Then 'Rollback
  Connection.Rollback
Else
  Connection.CommitTransaction
End If

Everything contained in the Recordset.ProcessData section is contained within the transaction and all actions will be either committed or rolled back at the end of the process.

As for the necessity of doing a rollback etc for an addnew/update, it all depends on your database, the criticality of the data etc.
0
 
LVL 2

Accepted Solution

by:
corvanderlinden earned 50 total points
Comment Utility
If you do not use transactions and the AddNew or Update fails you do not need to rollback, it just fails
0
 
LVL 5

Expert Comment

by:rkot2000
Comment Utility
corvanderlinden is correct for the single action (insert/update) you have internal transactions.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Expert Comment

by:clangl
Comment Utility
Unless you are proposing that you are updating mutliple tables with in one transactions
sub thisSub()
On error goto ErrHandl
cn.BeginTrans
cn.execute(sqlstuff)
cn.execute(sqlStuff2)
cn.commit
exit sub sub

ErrHandl:
cn.Rollback
err.raise.....

end sub

0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi DoraMeMe,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: TimCottee and corvanderlinden

DoraMeMe, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange

TimCottee points for you at:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20463697.html
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now