Results 1 to 4 of 4

Thread: [RESOLVED] TransactionScope with SqlDataAdapter

  1. #1
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 01
    Location
    New Delhi , INDIA
    Posts
    857

    Resolved [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.
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  2. #2
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 01
    Location
    New Delhi , INDIA
    Posts
    857

    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
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

  3. #3
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 02
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    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.

  4. #4
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 01
    Location
    New Delhi , INDIA
    Posts
    857

    Re: TransactionScope with SqlDataAdapter

    Quote Originally Posted by mendhak View Post
    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.
    Vishal Marya, MCP .net 3.5
    My Site
    http://www.vstoolsgallery.com/
    http://visualstudiogallery.msdn.micr...b-f87a909b9266





    Please indicate what version of vb you use.
    Please mark your thread resolved using the Thread Tools above.
    -----------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •