//使用事务来处理多条数据,如果不成功则回滚
public void getCheckListSubmit()
{
string _conStr = "................";//连接字符串
OdbcConnection _odbcCon = new OdbcConnection(_conStr);
_odbcCon.Open();
OdbcTransaction trans = _odbcCon.BeginTransaction(IsolationLevel.ReadCommitted);
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = trans.Connection;
cmd.Transaction = trans;
string sqlStr = "";
try
{
sqlStr = ".................";
cmd.CommandText = sqlStr;
cmd.ExecuteNonQuery();
sqlStr2 = ".................";
cmd.CommandText = sqlStr2;
cmd.ExecuteNonQuery();
}
catch
{
trans.Rollback();
hidsysMsg.Value = "Insert Failed";
_odbcCon.Close();
return;
}
trans.Commit();
hidsysMsg.Value = "Insert Succeeded";
_odbcCon.Close();
}