dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: ADO.NET cross-base transactions Pin

  1. #1
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    Exclamation ADO.NET cross-base transactions Pin

    I made a simple transaction using ADO.NET:

    SqlTransaction tn;
    SqlConnection cn = new SqlConnection(/*connection string to 'Database1'*/);

    try {
    if (cn.State != ConnectionState.Open)
    {
    cn.Open();
    }
    }
    catch (SqlException ex)
    {
    Debug.Assert(false, ex.ToString());
    }

    tn = cn.BeginTransaction();
    SqlCommand cmd2 = ...


    This works nicely. However I would like to make some update statement in other database - 'Database2'. Is it possible to do that inside one ADO.NET transaction? If so, how?

    Thank you for help in advance.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,173

    Re: ADO.NET cross-base transactions Pin

    Check out TransactionScope.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)