title: Many transactions in the same tables,
body: <p>We use application in server with Sql server and it receive many SDF file from clients to update the SqlServer Data Base the update for many Tables and I use Transaction for this, the application in server used by multiple user than it possible to be two updates in the same time, and the two with transaction, the application throw an exception that table used by another transaction !! </p>
  
  <blockquote>
    <p>New transaction is not allowed because there are other threads running in the session.</p>
  </blockquote>
  
  <p>and the user have other task to do in the app with transaction too, for the moment if there's an update he have to wait until it finish. </p>
  
  <p>Any ideas?</p>
  
  <p>Update : there's some code for my fonction : this is my fonctions with transaction run in BackgroundWorker with timer : </p>
  
  <pre><code>         DbTransaction trans = ConnectionClass.Instance.MasterConnection.BeginTransaction();
             try
             {
               ClientDalc.UpdateClient(ChosenClient, trans);
               // other functions with the same transaction               
  
               trans.Commit();
             }
             catch (Exception ex)
             {
                trans.Rollback();
                return false;
             }
  </code></pre>
  
  <p>Update Client:</p>
  
  <pre><code>        public static bool UpdateClient(ClientEntity ChosenClient, DbTransaction trans)
      {
  
          bool retVal = true;
          string sql = "UPDATE ClientTable Set ........";
  
  
  
          try
          {
              using (DbCommand cmd = DatabaseClass.GetDbCommand(sql))
              {
                  cmd.Transaction = trans;
                  cmd.Parameters.Add(DatabaseClass.GetParameter("@Name", Client.Name));
                  //
                  cmd.ExecuteNonQuery();
              }
          }
          catch (Exception ex)
          {
              retVal = false;
          }
  
          return retVal;
      }
  </code></pre>
  
  <p>If I run any thing else in the same time that BackgroundWorker is in progress I got exception even is not a transaction </p>
  
  <blockquote>
    <p>ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.”</p>
  </blockquote>