?
Solved

Rollback using ADO.Recordset!

Posted on 2002-04-15
6
Medium Priority
?
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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
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!

 

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

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!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

764 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