忘了把代码贴上来了
在access或sql均能实现回滚,唯独vfp的dbf数据库不行,运行当中也没报错,也执行了rollback(),可是没起到作用....
string ole_connstring = @"Provider=VFPOLEDB.1;Data Source=C:\VfpSw\VfpSw\bin\Debug;";
OleDbConnection myConnection = new OleDbConnection(ole_connstring);
myConnection.Open();
OleDbCommand myCommand = myConnection.CreateCommand();
OleDbTransaction myTrans;
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted);
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;
try
{
= "insert into test1 (www) value('123')";
myCommand.ExecuteNonQuery();
= "insert into test2 (nnn) value(000)";
myCommand.ExecuteNonQuery();
();
}
catch (Exception eee)
{
myTrans.Rollback();
MessageBox.Show(eee.ToString());
}
第二条执行语句我故意写错:"insert into test2 (nnn) value(000)"; 运行出错,执行回滚。
结果第一条执行后并没回滚,一样插入记录到test1中....