title: System.Threading.ThreadAbortException error
body: <p>I have a webmethod that will call a <code>SaveEmployee()</code> function. </p>
  
  <p><code>WebMethod</code> function as following:</p>
  
  <pre><code>[WebMethod]
  public bool UpdateEmployee(DataSet dSet)  
  {
    try
    {
       COMAccess.Employee.SaveEmployee(Registry.GetDatabaseConnection(),dSet)
    } 
    catch (Exception ex) 
    {
      Log(ex.InnerException.ToString()
    }
  }   
  </code></pre>
  
  <p>and <code>SaveEmployee()</code> function is as following:  </p>
  
  <pre><code>public static bool SaveEmployee(string connection, DataSet dSet)
  {
    bool rtnVal = false;
    SqlConnection  conn = new SqlConnection(connection);
    conn.Open();
    SqlTransaction tran = conn.BeginTransaction();
    SqlCommand command = conn.CreateCommand();
    command.Connection = conn;
    command.Transaction = tran;
    command.CommandTimeout = 320;
    command.CommandText = "SP_UPDATE_EMPLOYEE";
    command.CommandType = System.Data.CommandType.StoredProcedure;
  
    try 
    {
       foreach(System.Data.DataRow dRow in dSet.Tables["Employee"].Rows)
       {
          command.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = dRow["EmployeeID"];
          command.Parameters.Add("@EmployeeName ", SqlDbType.VarChar).Value = dRow["EmployeeName"];
          command.ExecuteNonQuery(); 
          command.Parameters.Clear();             
       }
       tran.Commit();
       myVal = true;    
    }
    catch (Exception ex)
    {
       tran.Rollback();
       myVal = false;
    }
       return myVal;
    }
  </code></pre>
  
  <p>Anyway, I got the following <code>InnerException</code> message:</p>
  
  <pre><code>System.Threading.ThreadAbortException: Thread was being aborted.
  at SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr packet)
  at System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket(IntPtr packet, UInt32 error)
  at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
  at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
  at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
  at System.Data.SqlClient.TdsParserStateObject.ReadByte()
  at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
  at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
  at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
  at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
  at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
  at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
  at COMAccess.Employee.SaveEmployee(String connection, DataSet dSet)
  </code></pre>
  
  <p>I have no clue what is happening. can someone please enlighten me? thanks</p>