|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
help: sqltransactioni 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? >the problem is: I don't think this problem can happen. Because they are in the same>table c can not updated because of sqltransaction didn't update (commit) the >table a and b yet . 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 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 Show quote "John" wrote: > 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? > > > > 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)? Show quote "John" <J***@yahoo.com> wrote in message news:%234YpJWyQGHA.4956@TK2MSFTNGP09.phx.gbl... > 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? > > > 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 Show quote "Thomas H" <T@H> wrote in message news:OK4LW44QGHA.1096@TK2MSFTNGP11.phx.gbl... > 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)? > > "John" <J***@yahoo.com> wrote in message > news:%234YpJWyQGHA.4956@TK2MSFTNGP09.phx.gbl... >> 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? >> >> >> > > |
|||||||||||||||||||||||