//事务处理
SqlConnection con = new SqlConnection(@"server=20101124-0948\SQL2005;database=zhiyonglengku;uid=luanhui;pwd=px7034;");
con.Open();
SqlTransaction tran = con.BeginTransaction();
try
{
SqlCommand cmd1 = new SqlCommand(strinSql, con);
cmd1.Transaction = tran;
cmd1.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand(stroutSql, con);
cmd2.Transaction = tran;
cmd2.ExecuteNonQuery();
// Execute some commands, then commit the transaction
tran.Commit();
MessageBox.Show("出库成功!");
DataSet dspro = OpeDataBase.GetDataSet(strDataSetSql);
BindToDataGridView(dspro);
}
catch
{
tran.Rollback();
Common.WriteError(exp.Message);
MessageBox.Show(exp.Message);
}