By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,454 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,454 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Share this Question
Share on Google+
1 Reply


debasisdas
Expert 5K+
P: 8,127
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

Post your reply

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