Solved

Rollback using ADO.Recordset!

Posted on 2002-04-15
6
314 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

803 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