473,387 Members | 3,820 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,387 software developers and data experts.

How to Verify SQL Update Succeeded

In Access 2000, we are having a problem with some updates apparently not
succeeding. I am not sure whether the records to be updated are locked,
somebody is overwritng the changes, or what, but intermittently users
discover that records they are sure they updated are not showing the
changes.

I want to put a check in so that after I run the update I can check the
number of records affected (should always be one), or find some other way to
check what has happened.

The update is simple and works as follows:

currentdb.execute("Update [invoice] set [paiddate] = '20040101' Where IDKey
= 100;")

Is there a way to show how many records were affected by this statement?

Many thanks,
Mike Thomas

Nov 13 '05 #1
5 7052
Use the dbFailOnError switch to stop if any problems occur, and test
RecordsAffected to see how many were written:

Dim db As DAO.Database
Set db = CurrentDb()
db.Execute "UPDATE ...;", dbFailOnError
MsgBox "Records affected: " & db.RecordsAffected
Set db = Nothing

Note that dbFailOnError does not rollback after error. You can run a
transaction if you need that. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike Thomas" <mi**@ease.com> wrote in message
news:N%**********************@newssvr28.news.prodi gy.com...
In Access 2000, we are having a problem with some updates apparently not
succeeding. I am not sure whether the records to be updated are locked,
somebody is overwritng the changes, or what, but intermittently users
discover that records they are sure they updated are not showing the
changes.

I want to put a check in so that after I run the update I can check the
number of records affected (should always be one), or find some other way to check what has happened.

The update is simple and works as follows:

currentdb.execute("Update [invoice] set [paiddate] = '20040101' Where IDKey = 100;")

Is there a way to show how many records were affected by this statement?

Many thanks,
Mike Thomas

Nov 13 '05 #2
Allen, Thanks again for your help.

Mike Thomas
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40**********************@per-qv1-newsreader-01.iinet.net.au...
Use the dbFailOnError switch to stop if any problems occur, and test
RecordsAffected to see how many were written:

Dim db As DAO.Database
Set db = CurrentDb()
db.Execute "UPDATE ...;", dbFailOnError
MsgBox "Records affected: " & db.RecordsAffected
Set db = Nothing

Note that dbFailOnError does not rollback after error. You can run a
transaction if you need that. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike Thomas" <mi**@ease.com> wrote in message
news:N%**********************@newssvr28.news.prodi gy.com...
In Access 2000, we are having a problem with some updates apparently not
succeeding. I am not sure whether the records to be updated are locked,
somebody is overwritng the changes, or what, but intermittently users
discover that records they are sure they updated are not showing the
changes.

I want to put a check in so that after I run the update I can check the
number of records affected (should always be one), or find some other
way to
check what has happened.

The update is simple and works as follows:

currentdb.execute("Update [invoice] set [paiddate] = '20040101' Where

IDKey
= 100;")

Is there a way to show how many records were affected by this statement?

Many thanks,
Mike Thomas


Nov 13 '05 #3
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:40**********************@per-qv1-newsreader-01.iinet.net.au:
Note that dbFailOnError does not rollback after error. You can run
a transaction if you need that. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html


Good lord -- how did I miss that one? I've always assumed that
dbFailOnError *does* entirely roll back the transaction.

Oy.

Well, looks like I need another alteration to my ExecuteSQL code, to
wrap the whole thing in a transaction.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:40**********************@per-qv1-newsreader-01.iinet.net.au:
Note that dbFailOnError does not rollback after error. You can run
a transaction if you need that. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html


Actually, rewriting my ExecuteSQL code, I'm wondering if:

DBEngine.Workspaces(0).BeginTrans
db.Execute strSQL, dbFailOnError
DBEngine.Workspaces(0).CommitTrans

where db is a database reference created with CurrentDB(), will
work? Or do I have to instantiate the db variable after the
beginning of the transaction, as a child of the workspace?

Or if I'm using a cached db variable or setting it to CurrentDB()
just before beginning the transaction, am I OK?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5
How you missed it, David, was that it DID roll back in Access 95 and
earlier. Microsoft mulitated it in Access 97 without documenting the change
in the help file: you had to read the readme to find out!!!

To answer your other question, I imagine (without testing) that creating a
Currentdb() object after beginning the transaction would work, because it
creates a new object that points to dbEngine(0)(0) which is in the
transaction. You may want to test it and check.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn*********************************@24.168.12 8.74...
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:40**********************@per-qv1-newsreader-01.iinet.net.au:
Note that dbFailOnError does not rollback after error. You can run
a transaction if you need that. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html


Good lord -- how did I miss that one? I've always assumed that
dbFailOnError *does* entirely roll back the transaction.

Oy.

Well, looks like I need another alteration to my ExecuteSQL code, to
wrap the whole thing in a transaction.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Axle | last post by:
Hi, This has been giving me trouble for a while. I want to verify a URL (if it exists) with VB6, because sometimes the URL (my server) shuts down, so basically I just want it to ping a redirect...
0
by: Zap | last post by:
I'm having trouble verifying the cookie that I leave on a client's computer. Here is the code: <% Dim sPath, filesys, count, getValue, update, twohrs sPath =...
2
by: Bob Rivers | last post by:
Hi, Is it possible to verify, using js, if ANY item in a form has changed? For example: I have a <form> with multiple items (<input>, <select>, <textarea>, etc). I need to track if one (or...
0
by: Support | last post by:
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> <head>...
1
by: Wayne | last post by:
I've created a form that has many option boxes to help users choose items (I need option boxes vs. combo boxes because they can choose multiple items per category). I've created an update query...
1
by: Riley DeWiley | last post by:
I have an UPDATE query that is always setting 0 records. When I cut and paste the SQL into Access and use it, it fails in the same way unless I coerce the date fields to be '=now()', in which case...
4
by: Kathy Burke | last post by:
Hi, I asked this question last week, but still need some help. When I do an update to a database record (SQL Server), how would I do the code to verify that the update event has happened? I can't...
3
by: jpr | last post by:
Hello, I have a form on which I have a cmdbutton to copy a couple of fields into another table (MASTER) using the SSN on the active form as criteria. In the active form (based on a tables...
60
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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...

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.