help: sqltransaction

J

John

i need advice to my problems as follow:

i need to update 3 table (say table a, table b and table c) using
sqltransaction (because i want all transaction either commit or > rollback).
table c will be updated after table a and table b updated.
the problem is:
table c can not updated because of sqltransaction didn't update (commit) the
table a and b yet .
any idea how to solve this problem?
 
T

Truong Hong Thi

the problem is:
table c can not updated because of sqltransaction didn't update (commit) the
table a and b yet .
I don't think this problem can happen. Because they are in the same
transaction, changes should be visible. Uncommitted changes made inside
a transaction are only invisible to other transactions (unless they
have IsolationLevel set to ReadUncommitted).

Thi
 
G

Guest

Hi John,

If the three tables are in the same transaction, then each one will be
updated sequentially. If you commit the transaction, all three updates will
be saved; if you rollback the transaction, all three updates will be
discarded. Changes will be made just as if they weren't performed in a
transaction. It's only when you Commit or rollback that the transaction has
any effect. In short, what you're doing should work.
I hope that helps
Ant
 
T

Thomas H

Like everyone said; what you're doing should work... are you using the same
connection object when you update all three tables? Are there any triggers
on those tables that could be interfering with your update on table C (such
as a primary key change/commit)?
 
J

John

maybe i didn't make clear explanation and i'm sorry for that.
i'm going to explain again the issue:

table c can create new record if table c see there is new record in table a
and table b.
i use the same connection and sqltransaction to update all tables (a,b and
c)
first the algorithm add new record in table a, and add new record in table
b, and finally create a new record in table c (once again if tabel a and b
updated, those table related by parent (tabel c) and child (tabel a,b)
relation)
when debugger execute tabel c, it come up with error.
the error cause because no childs (tabel a,b) exists.

thanks, hope make you better understand with my problem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top