title: SqlTransaction not committing - C#
body: <p>I am using <code>SqlTransaction</code> for updating data from a DataTable to a SQL Server table.</p>
  
  <p>The code is working great without any errors. But changes aren't reflected in the table for some reason. Not a single error encountered.</p>
  
  <p>Below is my C# code (not entire code)</p>
  
  <pre><code>using (con)
  {
      if (con.State == ConnectionState.Closed || con.State == ConnectionState.Broken)
          con.Open();
  
      using (SqlTransaction trans = con.BeginTransaction())
      {
          using (SqlCommand cmd = new SqlCommand(strCommand, con, trans))
          {
              using (SqlDataAdapter da = new SqlDataAdapter(cmd))
              {
                  SqlCommandBuilder cmb = new SqlCommandBuilder(da);
  
                  da.InsertCommand = cmb.GetInsertCommand();
                  da.UpdateCommand = cmb.GetUpdateCommand();
                  // da.DeleteCommand = cmb.GetDeleteCommand(); 
  
                  da.InsertCommand.Transaction = trans;
                  da.UpdateCommand.Transaction = trans;
  
                  da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
  
                  da.Fill(sourceDt);
  
                  if (sb.Length &gt; 0)
                  {
                      trans.Rollback();
                      throw new Exception(sb.ToString());
                  }
  
                  sourceDt.Merge(clonedDt, false, MissingSchemaAction.AddWithKey);
  
                  try
                  {
                      noOfRowsAffected = da.Update(sourceDt);
                      trans.Commit();    // Commit the changes to database
                  }
                  catch (Exception ex)
                  { }
  
                  if (noOfRowsAffected &gt; 0)
                  { 
                      Boolean success = true; 
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Please mark changes if I am missing anything.</p>