title: lock table after BeginTransaction MySql Transaction in c#.net
body: <p>How do i restrict other users to update or insert in a table after a certain transaction has begun ?</p>
  
  <p>I tried this :</p>
  
  <pre><code>MySqlConnection con = new MySqlConnection("server=localhost;database=data;user=root;pwd=;");
  con.Open();
  
  MySqlTransaction trans = con.BeginTransaction();
  
  try
  
          {
  
              string sql = "insert INTO transaction_ledger (trans_id,voucher_id,voucher_number,trans_date,ledger_code,company_code,trans_type, trans_amount,primary_ledger,narration,ledger_parent,trans_type_name,ledger_ref_code,r_trans_id,IsSync) VALUES (0, 'EReceipt-4',4,'2013-04-01','483', '870d7d83-05ec-4fbb-8e9d-801150bd3ed1', 'EReceipt',-233.22,1,'asadfsaf','Bank OD A/c','Receipt','4274',1173,'N')";
  
              new MySqlCommand(sql, con, trans).ExecuteNonQuery();
  
              sql = "insert INTO transaction_ledger (trans_id,voucher_id,voucher_number,trans_date,ledger_code,company_code,trans_type, trans_amount,primary_ledger,narration,ledger_parent,trans_type_name,ledger_ref_code,r_trans_id,IsSync) VALUES (0, 'EReceipt-4',4,'2013-04-01','4274', '870d7d83-05ec-4fbb-8e9d-801150bd3ed1', 'EReceipt',100,0,'asadfsaf','Sundry Creditors','Receipt','483',1173,'N')";
  
              new MySqlCommand(sql, con, trans).ExecuteNonQuery();
  
              sql = "insert INTO transaction_ledger (trans_id,voucher_id,voucher_number,trans_date,ledger_code,company_code,trans_type, trans_amount,primary_ledger,narration,ledger_parent,trans_type_name,ledger_ref_code,r_trans_id,IsSync) VALUES (0, 'EReceipt-4',4,'2013-04-01','427', '870d7d83-05ec-4fbb-8e9d-801150bd3ed1', 'EReceipt',133.22,0,'asadfsaf','Sundry Creditors','Receipt','483',1173,'N')";
  
              new MySqlCommand(sql, con, trans).ExecuteNonQuery();
  
  
              trans.Commit();
          }
          catch (Exception ex)
          {
  
              trans.Rollback();
          }
          finally
          {
              con.Close();
          }
  </code></pre>
  
  <p>but this still allows to insert rows after BeginTransaction.</p>