Solved

Rollback using ADO.Recordset!

Posted on 2002-04-15
6
324 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
ID: 6941384
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
ID: 6941480
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
ID: 6942075
corvanderlinden is correct for the single action (insert/update) you have internal transactions.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:clangl
ID: 6943105
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
ID: 7654082
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
ID: 7755273
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 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