PC Review


Reply
Thread Tools Rate Thread

ADO .NET Transactions rollback ( URGENT )

 
 
João Santa Bárbara
Guest
Posts: n/a
 
      18th Aug 2005
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


 
Reply With Quote
 
 
 
 
W.G. Ryan MVP
Guest
Posts: n/a
 
      18th Aug 2005
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" <(E-Mail Removed)> wrote in message
news:e2Xu61$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT...Please suggest how can we implement transactions at BAL in 3 tier architecture not in DAL. ravi.vaswani@gmail.com Microsoft ADO .NET 1 28th Feb 2006 02:05 PM
ADO .NET Transactions rollback ( URGENT ) João Santa Bárbara Microsoft Dot NET 1 18th Aug 2005 03:28 PM
DataSet Transactions Rollback [HELP PLEASE] Brian Scott Microsoft ADO .NET 2 19th May 2005 06:46 PM
access 2003 and transactions commit-rollback =?Utf-8?B?bWFkaG91c2U=?= Microsoft Access Form Coding 1 8th Nov 2004 11:51 AM
Mixing ADO.NET transactions and Stored Procedure Transactions James Walker Microsoft ADO .NET 1 27th May 2004 11:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:35 AM.