473,408 Members | 1,875 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,408 software developers and data experts.

ws rollback dosent work

157 100+
At least not the way i would think it should

Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset
  2. Dim ws As Workspace
  3. Set ws = DBEngine.Workspaces(0)
  4.  
  5. With rst
  6. ws.BeginTrans
  7.     .Open "SELECT * from [test]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  8.     .AddNew
  9.     !test = "test2"
  10.     .Update
  11.     .Close
  12.  
  13.     If MsgBox("vil du avbryte?", vbYesNo, "logidose") = vbYes Then
  14.         MsgBox "rollback"
  15.         ws.Rollback
  16.         Exit Sub
  17.     End If
  18.  
  19. ws.CommitTrans
  20.  
  21. End With
  22.  
  23.  
Selecting yes in the msgbox dosent rollback. Why?
Jun 17 '10 #1

✓ answered by ADezii


4 2487
MrDeej
157 100+
Found the problem

--
Dim ws As Workspace
Set ws = DBEngine.Workspaces(0)
--


Dim ws As ADODB.Connection
Set ws as currentproject.connection

---


First bulk is for DAO and second is for ADO. I needed ADO ie it didnt work.
Now it works fine :=)
Jun 17 '10 #2
MikeTheBike
639 Expert 512MB
@MrDeej
Hi

Not sure what the problem is (I tend to use ADO connections), but suggest this mod to the If statment
Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset 
  2. Dim ws As Workspace 
  3. Set ws = DBEngine.Workspaces(0) 
  4.  
  5. With rst 
  6. ws.BeginTrans 
  7.     .Open "SELECT * from [test]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic 
  8.     .AddNew 
  9.     !test = "test2" 
  10.     .Update 
  11.     .Close 
  12.  
  13.     If MsgBox("vil du avbryte?", vbYesNo, "logidose") = vbYes Then 
  14.         MsgBox "rollback" 
  15.         ws.Rollback 
  16.     Else
  17.         ws.CommitTrans 
  18.     End If 
  19.  
  20. End With 
and see if that does it!?

MTB
Jun 17 '10 #3
MrDeej
157 100+
Thanks, i already found the error.

This 2 only work for DAO:
Expand|Select|Wrap|Line Numbers
  1. Dim ws As Workspace  
  2. Set ws = DBEngine.Workspaces(0) 
New code wich works:
Expand|Select|Wrap|Line Numbers
  1. Dim rst As New ADODB.Recordset
  2. Dim ws As ADODB.Connection
  3. Set ws = CurrentProject.Connection
  4. With rst
  5.  
  6. ws.BeginTrans
  7.     .Open "SELECT * from [test]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  8.     .AddNew
  9.     !test = "test2"
  10.     .Update
  11.     .Close
  12.  
  13.     If test = True Then
  14.         MsgBox "rollback"
  15.         ws.RollbackTrans
  16.         Exit Sub
  17.     End If
  18.  
  19. ws.CommitTrans
  20.  
  21. End With
  22.  
  23.  
  24.  
Jun 17 '10 #4
ADezii
8,834 Expert 8TB
  1. DAO Transaction Processinig
    http://bytes.com/topic/access/insigh...rocessing-what
  2. ADO Transaction Processing
    http://bytes.com/topic/access/insigh...ion-processing
Jun 17 '10 #5

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

Similar topics

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...
3
by: level8 | last post by:
Hi, Everybody, I'm a Hungarian SQL user and I need a little help for SQL Server 7 ! I protect my table against bad data with a trigger. I use ROLLBACK and RAISERROR statement in this trigger....
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
6
by: Tor Heigre | last post by:
Hello While testing our code on DB2 we have encountered a difference in the behaviour of DB2Driver (com.ibm.db2.jcc.DB2Driver with driverType= 4) compared to the drivers offered by Oracle 9i and...
1
by: Patrick | last post by:
Hi, I have been trying to get the pointers to work in c#, i was told that you have to set Allow unsafe code in your application properties and that should do the trick, but it still dosent work, i...
7
by: Rich | last post by:
Hello, I have an SP that inserts data into a sqlserver table. If a condition is not met within the SP after the data has been inserted into the table, the SP will rollback the insert. If I...
2
by: Money | last post by:
When we do this Test *ptr=new Test; then runtime memory manager will allocate 10*sizeof(Test) + X bytes(X varying from implementation to implementation) But instead if I call operator new...
2
by: Ian Boyd | last post by:
We're encountering a situation where we're encountering a deadlock, and someone's been made the deadlock victim. But after that, DB2 refuses to run any SQL, and instead we get the error message: ...
13
by: newlearner | last post by:
hi, Im new into Ajax and Javascript, I have a doubt... I have a External javascript. and a couple of html files and I load These through ajax request and response. The html pages contain a...
2
by: rockystar | last post by:
I am trying to set the value for a select list..the code is as below...It works fine in firefox, but dosent work in IE ...need urgent help ... ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.