Results 1 to 3 of 3

Thread: mssql and mysql transaction

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    mssql and mysql transaction

    Hello There,
    im just curious on how to do this, 1 transaction and two different server queries inside it..

    ex:

    Code:
    BeginTransaction
    
    'MSSQL Query
    INSERT query
    
    'MYSQL Query
    INSERT query
    
    CommitTransaction
    the question is which transaction will im going to use?if i will going to use sqltransaction and mysql query failed on insert will be rolling back by not inserting the mssql also?..

    thanks
    glen

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: mssql and mysql transaction

    You have two choices:

    1. Use both. Begin the two transactions, perform all your data access against both databases, commit or rollback both transactions. That still leaves you vulnerable if there's an issue with the second commit, which is unlikely but possible.

    2. Use a single distributed transaction. Don't use a SqlTransaction or a MySqlTransaction. Wrap all your data access in a Using block with a TransactionScope object. That is the "proper" way to manipulate multiple data sources in an atomic manner. That said, I'm not sure that Connector/Net supports distributed transactions. You should give it a test run and see if it works with the latest version. If it doesn't, you may be able to add that support, although I don;t know exactly how. That would take some research.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Posts
    135

    Re: mssql and mysql transaction

    thank you for a very quick reply jmcilhinny.

    its lighten my way.i dont know about single distributed transaction.glad you mention it.its a new learning to me..for now,i just take a research on this..ill get back to you later..


    thank you,
    glen

Posting Permissions

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



Click Here to Expand Forum to Full Width