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

ADO .NET Transactions rollback ( URGENT )

Hi all
i have this problem .

i have 2 tables ( they are not master detail ) 2 simple tables, and i´m
doing a simple update just like this

try
Trans = Con.BeginTransaction
..........
DataAdpater1.Update(Table1) -> '10 rows Inserted in DataBase
DataAdapter2.Update(Table2) -> '10 rows Inserted in DataBase Sucess and
10 Unsucess

Trans.commit
cacth ex as exception
Trans.rollback
end try

Every Time i have an error i will run this code again ... and in the first
time i have done the rollback but in the second time all the records that
have been inserted ( in the first time ) are not inserted in the 2 time.
i saw all rows in the datatable and the row state is Unchanged when they
suposed to be Added ..

can someone help me .. ?

thks
JSB
Aug 18 '05 #1
1 1822
The problem is that the data Adapter is calling acceptchanges on each row as
it's updated. It's actually by desing. In the 2.0 Framework, there's a data
adapter property called AcceptChangesDuringUpdate that you can set to
false, call your update, and where you call commit, call
DataSet.AcceptChanges.
http://www.knowdotnet.com/articles/a...ingupdate.html
http://msmvps.com/williamryan/archiv...7/10/9888.aspx

In the meantime you can use GetChanges

DataSet ds1 = Table1sDataSet.GetChanges();
DataSet ds2 = Table2DataSet.GetChanges();
try
{
da1.Update(ds1.Tables[0]);
da2.Update(ds2.Tables[0]);
Trans.Commit();
OriginalDataSet1.AcceptChanges();
OriginalDataSet2.AcceptChanges();
}
catch (SqlException ex)
{
foreach(SqlError er in ex.Errors){
//Build your error message
}
Trans.rollback();
}
"Joăo Santa Bárbara" <jo****@i24portugal.com> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
Hi all
i have this problem .

i have 2 tables ( they are not master detail ) 2 simple tables, and i´m
doing a simple update just like this

try
Trans = Con.BeginTransaction
..........
DataAdpater1.Update(Table1) -> '10 rows Inserted in DataBase
DataAdapter2.Update(Table2) -> '10 rows Inserted in DataBase Sucess and
10 Unsucess

Trans.commit
cacth ex as exception
Trans.rollback
end try

Every Time i have an error i will run this code again ... and in the first
time i have done the rollback but in the second time all the records that
have been inserted ( in the first time ) are not inserted in the 2 time.
i saw all rows in the datatable and the row state is Unchanged when they
suposed to be Added ..

can someone help me .. ?

thks
JSB

Aug 18 '05 #2

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

Similar topics

6
by: Christopher J. Bottaro | last post by:
Hi, Why is there no support for explicit transactions in the DB API? I mean like transaction() to start the trans and commit() and rollback() would end the trans or something. The reason why I...
5
by: princevejita1 | last post by:
Hello I have problem with my MySQL server and transactions. I installed MySQL server 5.0.11 with MySQL administrator & MySql Query Browser on Win XP Prof. I would like to use transactions, so I...
4
by: Raposa Velha | last post by:
So, chosen the interface for my app, finally I got stuck with transactions. Boy!, how many ways of doing the same job are there?! Any suggestion so I could find myself in the right direction?...
11
by: Mike P | last post by:
I've been using C# transactions for a while and had no problems with them. Using try catch blocks I can trap basically all possible errors and rollback all necessary data. Over the last few...
9
by: John Sidney-Woollett | last post by:
Is it possible to use the dblink and dblink_exec features from inside pl/pgsql functions to mimic the behaviour of nested transactions by calling another function or executing some SQL via the...
1
by: John Wells | last post by:
On this page: http://www.compiere.org/technology/independence.html, the project leader of Compiere (a popular ERP package) states that the move to Postgres failed because of lack of support of...
1
by: Joăo Santa Bárbara | last post by:
Hi all i have this problem . i have 2 tables ( they are not master detail ) 2 simple tables, and i´m doing a simple update just like this try Trans = Con.BeginTransaction .............
2
by: RAM | last post by:
Hello, (Sorry for my English...) I am learning .NET 2.0 (C#, ASP.NET, ADO.NET etc.). I need to write a database application (SQL Server) consisting of a number of database transactions (like...
14
realin
by: realin | last post by:
Hiya all, after my 1-2 weeks research i finally found a more consistent way to fire mysql queries in php i.e. transactions. I have two options to insert data in multiple tables :: 1) through...
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:
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
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?
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.