adocon.BeginTrans;
try
//更新读者表押金字段
qryReaderInfoData.Close;
qryReaderInfoData.SQL.Text := sSQL1;
qryReaderInfoData.ExecSQL;
//写manager.charge_log
qryReaderInfoData.Close;
storeprocChargeLog.Close;
storeprocChargeLog.ExecProc;
if storeprocChargeLog.Parameters.ParamByName('@li_retu').Value = 1 then //执行不成功
begin
adocon.RollbackTrans;
Result := -1;
qryReaderInfoData.Close;
qryReaderInfoData.Free;
qryChargeLogData.Close;
qryChargeLogData.Free;
storeprocChargeLog.Close;
storeprocChargeLog.Free;
Exit;
end;
storeprocChargeLog.Close;
qryChargeLogData.Close;
qryChargeLogData.SQL.Text := sSQL;
qryChargeLogData.ExecSQL;
qryChargeLogData.Close;
adocon.CommitTrans;
Result := 100;
except
adocon.RollbackTrans;
Result := -1;
end;
我不知道我的代码哪错了,提示“在事务中,不能存在多个使用此游标类型的记录集”
try
//更新读者表押金字段
qryReaderInfoData.Close;
qryReaderInfoData.SQL.Text := sSQL1;
qryReaderInfoData.ExecSQL;
//写manager.charge_log
qryReaderInfoData.Close;
storeprocChargeLog.Close;
storeprocChargeLog.ExecProc;
if storeprocChargeLog.Parameters.ParamByName('@li_retu').Value = 1 then //执行不成功
begin
adocon.RollbackTrans;
Result := -1;
qryReaderInfoData.Close;
qryReaderInfoData.Free;
qryChargeLogData.Close;
qryChargeLogData.Free;
storeprocChargeLog.Close;
storeprocChargeLog.Free;
Exit;
end;
storeprocChargeLog.Close;
qryChargeLogData.Close;
qryChargeLogData.SQL.Text := sSQL;
qryChargeLogData.ExecSQL;
qryChargeLogData.Close;
adocon.CommitTrans;
Result := 100;
except
adocon.RollbackTrans;
Result := -1;
end;
我不知道我的代码哪错了,提示“在事务中,不能存在多个使用此游标类型的记录集”
建议楼主把事务方式改一下试试:
adocon.BeginTrans;
try
....
adocon.CommitTrans;
showmessage('保存成功');
except
adocon.RollbackTrans;
showmessage('保存失败了,请检查');
end;