如何使用事务? (100分)

  • 主题发起人 苍山@狼
  • 开始时间

苍山@狼

Unregistered / Unconfirmed
GUEST, unregistred user!
我运行事务程序,就出错,提示为:
‘Operation not applicable.Transaction not available.’
我用的是BDE控件,数据库为Informix;代码如下:
qryFp.Close ;
Database1.StartTransaction ;
try
qryFp.sql.Text :='select sflsh from mz_sflsh where sfrq=:dtSfrq ';
qryFp.ParamByName('dtSfrq').AsDate :=dtSfrq ;
qryFp.Active:=True;
//读取系统日期完毕

//判断是否为空
//为空则插入一条
if qryFp.Eof then
begin
qryLsh.Close;
qryLsh.sql.Text :='Insert into mz_sflsh values:)dtSfrq,1) ';
qryLsh.ParamByName('dtSfrq').AsDate :=dtSfrq;
qryLsh.Execsql;
end
//插入完毕

//不为空则更新流水号
else
begin
intSflsh:=qryFp.FieldByName('sflsh').AsInteger ;
intSflsh:=intSflsh+1;
qryLsh.Close;
qryLsh.sql.Text :='update mz_sflsh set sflsh=:intSflsh where sfrq=:dtSfrq ';
qryLsh.ParamByName('intSflsh').AsInteger :=intSflsh;
qryLsh.ParamByName('dtSfrq').AsDate :=dtSfrq;
qryLsh.ExecSQL;
end;
//更新完毕
Database1.Commit ;
Except
Database1.Rollback ;
end;
请高手指教。
 
没有用过 Informix数据库
但从语句上看,似乎没有问题
不知你的database 连接是否有问题
 
连接没有问题,我可以执行查询、插入和更新;
但是,一到执行上面的语句就出错;
是不是database有什么特别的设置
 
DataBase1.TransIsolation := tiRepeatableRead;
 
DataBase1.TransIsolation := tiRepeatableRead;
DataBase1.TransIsolation := tiDirtyRead;
DataBase1.TransIsolation := tiReadCommitted;
这三个我都试过了,不行;
难道非的用ADO/COM+
 
对这样的数据库 ,事件不适用。这种数据库没有事件概念!!!!!!
 
出错提示就是不支持事务嘛。
 
确实是数据库不支持事务;因为我用的这个数据库在建的时候,没有建日志文件,
所以不支持事务;
我现在用一个有日志的数据库执行上面的代码就没出错;
谢谢各位!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
508
import
I
顶部