473,434 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

rollback and commit transaction using VB 6.0 as development tool and sql server as ba

Hi,

Database: SQL Server 2000
Development Tool: VB 6.0

In a save button, i have several insert and update statement that has to be executed. In case of failure of any of the statement, i want to revert back to the state prior i had started the insert and update statement.

Could you please tell me how can i do so with VB as development tool and SQL Server as database?
Oct 29 '07 #1
1 15039
debasisdas
8,127 Expert 4TB
try this sample code

Expand|Select|Wrap|Line Numbers
  1. SQL = "insert into tabel_name values..........."
  2. con.BeginTrans
  3. On Error GoTo ProcError
  4. con.Execute SQL
  5. con.CommitTrans
  6. MsgBox "Data Transferred...!"
  7. ProcError:
  8. If Err.Number <> 0 Then
  9. con.RollbackTrans
  10. MsgBox Err.Number & "   " & Err.Description
  11. End If
  12.  
Oct 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alice | last post by:
Hi all, I have a problem with rollback segment. I am a beginner and do not have much knowledge of DBA. Anyways, the problem is there is a transaction of around 105 MB. This would not fit...
1
by: anders_tung | last post by:
Hi, I have a procedure which will call 3 functions. First function will update a record. Second function will delete a record. Third function will insert a record. Each function will return...
2
by: mahajan.sanjeev | last post by:
Hi, I am having problems with rollback using the SQLTransaction object. I am trying to insert records in two tables in a transaction. I want to rollback all the changes if any exception occurs...
1
by: Jason Huang | last post by:
Hi, I am just wondering how do we test the transaction's Commit and Rollback? How do we simulate a situation to let the transaction fail then Rollback? Thanks for help. Jason
8
by: Michael Paesold | last post by:
I just read this in the MySQL manual: (http://dev.mysql.com/doc/mysql/en/InnoDB_Error_handling.html) "Error handling in InnoDB is not always the same as specified in the SQL standard. According...
1
by: jacob.miles | last post by:
Hello. I'm trying to wrap a function call in a transaction, but when I intentionally throw an exception in the middle of the function it doesn't actually roll back the transaction. The debug...
2
by: campbell_canuck | last post by:
Hello and TIA, I am trying to write some VB code to move some data between 2 Access databases using a code module in Access. As part of it, I am trying to use transactions. However, by the...
2
by: NarutoFanatic | last post by:
Hello, I'm having trouble using a transaction - rollback statement in sql. I can't seem to have the rollback executed during an error when i've altered a table to add a column with the same name...
5
by: keirnus | last post by:
Hello, I am using Datasheet view when displaying my data. The data are displayed in a "x,y" matrix wherein data can be directly edited in the Datasheet. Anything inputted in a certain cell...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.