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

Transactions for linked SQL Server Tables?

Hello,
I have a VBA/Database application which reads files, analyzes them,
updates a database, and then moves them to an archive. I would like to
make this an atomic transaction -- that is, if the move to the archive
fails, I don't want the database to be updated (and if the database
update fails, I don't want the file moved...)

The logic I want is as follows:

Begin transaction

Read file

Update TableOne
Update TableTwo

Move file

End transaction

On Error: Rollback transaction

TableOne and TableTwo are linked tables from a SQL Server database.
TableTwo contains a foreign key which points to an entry in TableOne
(so adding the TableTwo entry fails if TableOne's entry hasn't been
added yet). They are accessed using the RecordSet object.

I have the code working without the transactions. But when I add them
(using DBEngine.Workspaces(0).BeginTrans, etc.) I recieve an ODBC error
when I attempt to update TableTwo.

Is there any other way to begin, end, and rollback a transaction
(perhaps on the SQL Server side?) And how would I invoke this in
Access 2003?

Thanks,
-Aaron

Nov 13 '05 #1
3 4629
Use Access97/Jet 3.5, or ADO, or stored procedures.

ODBC transactions are broken in DAO 3.6, and the more
work you put in, the more you realise how broken it
is.

Regarding your specific problem: you can't do that
with DAO 3.6. You might be able to make it work by
using an append query instead of an update query.

(david)

"Ace Calhoon" <ac********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello,
I have a VBA/Database application which reads files, analyzes them,
updates a database, and then moves them to an archive. I would like to
make this an atomic transaction -- that is, if the move to the archive
fails, I don't want the database to be updated (and if the database
update fails, I don't want the file moved...)

The logic I want is as follows:

Begin transaction

Read file

Update TableOne
Update TableTwo

Move file

End transaction

On Error: Rollback transaction

TableOne and TableTwo are linked tables from a SQL Server database.
TableTwo contains a foreign key which points to an entry in TableOne
(so adding the TableTwo entry fails if TableOne's entry hasn't been
added yet). They are accessed using the RecordSet object.

I have the code working without the transactions. But when I add them
(using DBEngine.Workspaces(0).BeginTrans, etc.) I recieve an ODBC error
when I attempt to update TableTwo.

Is there any other way to begin, end, and rollback a transaction
(perhaps on the SQL Server side?) And how would I invoke this in
Access 2003?

Thanks,
-Aaron

Nov 13 '05 #2
Thanks for the help, I have it working now. Here are a couple of notes
for archival purposes.

Switching to ADO worked. However, it would require quite a bit of code
rewriting (because I was taking advantage of some queries to convert
names on the SQL Server database to something more recognizable).

I ran around in circles for a little while, because the database *had*
been working relatively recently. Eventually I just deleted all of the
links to the tables and recreated them... That appears to have done
the trick. I must have messed something up when I was experimenting
with the link table editor.

Nov 13 '05 #3
On 12 Sep 2005 08:30:11 -0700, "Ace Calhoon" <ac********@gmail.com> wrote:
Thanks for the help, I have it working now. Here are a couple of notes
for archival purposes.

Switching to ADO worked. However, it would require quite a bit of code
rewriting (because I was taking advantage of some queries to convert
names on the SQL Server database to something more recognizable).

I ran around in circles for a little while, because the database *had*
been working relatively recently. Eventually I just deleted all of the
links to the tables and recreated them... That appears to have done
the trick. I must have messed something up when I was experimenting
with the link table editor.


I just wanted to add a that holding transactions open on the front-end is not
a good practice if you can avoid it, regardless of the data access library
used - particularly for long-running batches. If I need to do batch
processing on the front-end, what I do is write records to a table that
describes the transactions to be done, then call a stored procedure on the
server to actually process the batch.

If multi-user updates are an issue, you can do a form of optimistic locking by
storing TIMESTAMP field values in the transaction table, and checking them
from inside the transaction in the stored procedure.

Nov 13 '05 #4

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

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
2
by: gabriel | last post by:
Greetings, I am adding foreign keys to a database and saving the generated scripts. What I do not understand is that all script begin with empty transactions. Why ? Example follows : /*
4
by: Neil Ginsberg | last post by:
I have ODBC linked tables to a SQL 7 database in an A2K database. The linked tables do not have the password stored in them, so the first time the user accesses them, they need to enter the SQL...
1
by: Nico | last post by:
Hi! I use Windows XP and Access 2002 (XP) SP2 (not SP3) My company has not upgraded to SP3. My problem: -I have a form "F_BOMs" -in this form, i have a sub form called "SF_BOMs" -the sub-form...
15
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? ...
1
by: S. van Beek | last post by:
Dear reader, How to increase the response in case of working with linked tables, program in frond end mdb and tables in back end mdb. For possible combinations and their response...
2
by: Adnan | last post by:
Hey Ppl, I'm developing an Online Auction Site using ASP.net and am experiencing a problem with Transactions in ADO.Net. When beginTrasaction() function is invoked from a specific connection,...
3
by: Bret Kuhns | last post by:
I recently started a co-op/internship at a company and they are looking to migrate a large legacy supported application from OLEDB to SQL Server. I'm doing prelim work in experimenting with the...
3
by: psycho | last post by:
I am working on an N-tier application using following components: 1. Data Access Layer using DLINQ which consists of Data Context class and Table Mapping classes. 2. Business Logic Layer....
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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,...

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.