none
parallel transactions error RRS feed

  • Question

  •  

    Hi,All.

    I'm writing test cases on C# for a few methods that make changes in database.To prevent making changes I used BeginTransaction-Rollback,everything was good.But this doesn't work if tested method has BeginTransaction-Rollback code itself.An error appears in NUnit: System.InvalidOperationException : SqlConnection does not support parallel transactions. 
    Do smb know how to solve the problem?

     *******************************tc below********************

    [Test]

    [Category("Access")]

    public void UpdateGroupUserTable(/*Int32 userID, GroupList dataset*/)

    {

    r.BeginTransaction();

    try

    {

    r.UpdateGroupUserTable(userId,gl);

    }

    finally

    {

    r.Rollback();

    }

     *******************************tested method below********************

    public void UpdateGroupUserTable(Int32 userID, GroupList dataset)

    {

    CheckDisposed();

    UpdateCommand.CommandType = CommandType.Text;

    UpdateCommand.Parameters.Clear();

    UpdateCommand.Parameters.Add("@USERID", userID);

    BeginTransaction();

    try

    {

    Adapter.Update(dataset.acl_group);

    Commit();

    }

    catch (SqlException)

    {

    Rollback();

    throw;

    }

    }

    Tuesday, August 21, 2007 11:04 AM