|
-
Jul 10th, 2009, 12:18 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] TransactionScope with SqlDataAdapter
I want to use transaction based updates for my application.
i use SqlDataAdapter and SqlCommandBuilder for inserts and updates.
And the sqlconnection is created at application startup.
But the Transactions.TransactionScope works if the sqlconnection is created inside the scope.
I there any other way i can implement transactions.
Last edited by vishalmarya; Jul 10th, 2009 at 12:21 AM.
-
Jul 10th, 2009, 12:41 AM
#2
Thread Starter
Fanatic Member
Re: TransactionScope with SqlDataAdapter
ok I can use EnlistTransaction with my existing Connection Object
MyConnObject.EnlistTransaction(System.Transactions.Transaction.Current).
http://connect.microsoft.com/VisualS...edbackID=97722
-
Jul 10th, 2009, 09:48 AM
#3
Re: TransactionScope with SqlDataAdapter
You shouldn't be creating a connection on application startup anyways as that's bad practice. You ideally want to create the connection as late as possible and then pass that to the adapter.
-
Jul 13th, 2009, 05:47 AM
#4
Thread Starter
Fanatic Member
Re: TransactionScope with SqlDataAdapter
 Originally Posted by mendhak
You shouldn't be creating a connection on application startup anyways as that's bad practice. You ideally want to create the connection as late as possible and then pass that to the adapter.
thanks mendhak.
It means i should open the connection every time i need it ?
Is using EnlistTransaction recommended ?
Actually my application deals with multiple databases.
when i used EnlistTransaction for another database within the same transaction scope , it gave the MSDTC error.
i enabled it from the control panel.
But is this the right way to do it or i am unnecessarily creating a distributed transaction.
( my requirement is to update multiple tables in a single transaction scope and these tables reside across databases )
Please guide.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|