I have two tables in dataset, and appropriate TableAdapters.

How can i update both tables, but in transaction?

I other words:

THIS:
MyDSTableAdapters.Table1TableAdapter a1 = new ...
MyDSTableAdapters.Table1TableAdapter a2 = new ...

a1.Update(dt1);
a2.Update(dt2);

but where to put transaction ?

P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
ServerExplorer drag n' drop

Re: update DataSet - transaction by W

W
Tue Nov 14 09:38:08 CST 2006

You can just declare and instantiate it right before the Update statements,
Try/catch the Updates, Rollback on exception.
"TheMaxx" <themaxxREMOVE@net.hr> wrote in message
news:ejciit$55$1@magcargo.vodatel.hr...
>I have two tables in dataset, and appropriate TableAdapters.
>
> How can i update both tables, but in transaction?
>
> I other words:
>
> THIS:
> MyDSTableAdapters.Table1TableAdapter a1 = new ...
> MyDSTableAdapters.Table1TableAdapter a2 = new ...
>
> a1.Update(dt1);
> a2.Update(dt2);
>
> but where to put transaction ?
>
> P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
> ServerExplorer drag n' drop
>



Re: update DataSet - transaction by Cor

Cor
Tue Nov 14 23:02:34 CST 2006

The Max,

In 1.x it is in connection. setTransaction in 2.0 there is a Transaction
class.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqltransactionclasstopic.asp

I hope this helps,

Cor

"TheMaxx" <themaxxREMOVE@net.hr> schreef in bericht
news:ejciit$55$1@magcargo.vodatel.hr...
>I have two tables in dataset, and appropriate TableAdapters.
>
> How can i update both tables, but in transaction?
>
> I other words:
>
> THIS:
> MyDSTableAdapters.Table1TableAdapter a1 = new ...
> MyDSTableAdapters.Table1TableAdapter a2 = new ...
>
> a1.Update(dt1);
> a2.Update(dt2);
>
> but where to put transaction ?
>
> P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
> ServerExplorer drag n' drop
>



Re: update DataSet - transaction by TheMaxx

TheMaxx
Wed Nov 15 02:30:28 CST 2006

Cor & Ryan, thanx for answers, but i think we are missing a point.
I am well aware of SqlTransaction object, but how to set the same
transaction for each TableAdapter?

p.s. this is 2.0, i think TableAdapters were not provided in VS 2003



"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:emfnCMHCHHA.4832@TK2MSFTNGP06.phx.gbl...
> The Max,
>
> In 1.x it is in connection. setTransaction in 2.0 there is a Transaction
> class.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqltransactionclasstopic.asp
>
> I hope this helps,
>
> Cor
>
> "TheMaxx" <themaxxREMOVE@net.hr> schreef in bericht
> news:ejciit$55$1@magcargo.vodatel.hr...
>>I have two tables in dataset, and appropriate TableAdapters.
>>
>> How can i update both tables, but in transaction?
>>
>> I other words:
>>
>> THIS:
>> MyDSTableAdapters.Table1TableAdapter a1 = new ...
>> MyDSTableAdapters.Table1TableAdapter a2 = new ...
>>
>> a1.Update(dt1);
>> a2.Update(dt2);
>>
>> but where to put transaction ?
>>
>> P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
>> ServerExplorer drag n' drop
>>
>
>



Re: update DataSet - transaction by Cor

Cor
Wed Nov 15 12:41:20 CST 2006

The Max, I had some problems with this in past because the updatecommand is
privat so if it does not go, is here the oldmetod which is as well in
sqlclient

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbconnectionclassbegintransactiontopic.asp

However, I thuougth that I solved with casting the tableadapter again to a
dataadapter and than add the transaction to that.


Cor

"TheMaxx" <themaxxREMOVE@net.hr> schreef in bericht
news:ejeiqr$4bv$1@magcargo.vodatel.hr...
> Cor & Ryan, thanx for answers, but i think we are missing a point.
> I am well aware of SqlTransaction object, but how to set the same
> transaction for each TableAdapter?
>
> p.s. this is 2.0, i think TableAdapters were not provided in VS 2003
>
>
>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:emfnCMHCHHA.4832@TK2MSFTNGP06.phx.gbl...
>> The Max,
>>
>> In 1.x it is in connection. setTransaction in 2.0 there is a Transaction
>> class.
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqltransactionclasstopic.asp
>>
>> I hope this helps,
>>
>> Cor
>>
>> "TheMaxx" <themaxxREMOVE@net.hr> schreef in bericht
>> news:ejciit$55$1@magcargo.vodatel.hr...
>>>I have two tables in dataset, and appropriate TableAdapters.
>>>
>>> How can i update both tables, but in transaction?
>>>
>>> I other words:
>>>
>>> THIS:
>>> MyDSTableAdapters.Table1TableAdapter a1 = new ...
>>> MyDSTableAdapters.Table1TableAdapter a2 = new ...
>>>
>>> a1.Update(dt1);
>>> a2.Update(dt2);
>>>
>>> but where to put transaction ?
>>>
>>> P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
>>> ServerExplorer drag n' drop
>>>
>>
>>
>
>



Re: update DataSet - transaction by TheMaxx

TheMaxx
Fri Nov 17 02:32:43 CST 2006

I think you finally got me!
This is an answer i was looking for.
But it just feels like a walkaround instead a straight forward, 'by the book
(MSDN)' stuff.
It's hard to belive that Microsoft did not provide something simpler for a
common functionality.

Why introducing TableAdapters when transaction is not provided for them?
Also i can hardy belive that TableAdapters do not have a base class (or
interface) so it's making it hard to program generic solution for them.


> However, I thuougth that I solved with casting the tableadapter again to a
> dataadapter and than add the transaction to that.
>