procedure Tservertransaction.exesql(const str :widestring);
var I:integer;
begin
i:=0;
Fado.BeginTrans;
if i=3 then
begin
application.MessageBox('该次数据导入出现错误已达5次,请检查!','导入失败',MB_ok);
exit;
end;
try
Fado.Execute(str);
Fado.CommitTrans;
except
Fado.RollbackTrans; end;
end;procedure Tservertransaction.exealltxt;
var
fs: TsearchRec;
tmps:TStringlist;
str,fpath :widestring;
begin
fpath :=ExtractFiledir(Application.Exename);
if findfirst(fpath+'\*.txt',faAnyFile,fs)<>0 then
begin
Application.MessageBox('没有数据文件!','错误',MB_ICONERROR);
exit;
end;
repeat
if (fs.name<>'.') and (fs.name<>'..') then
if((fs.Attr and faDirectory)=faDirectory) then
exeAlltxt
else begin
tmps:=TStringList.Create;
tmps.LoadFromFile(fpath+'\'+fs.name);
str :=listtostr(tmps);//listtostr是我自定义的函数,是将stringlist里的数 据 入到一个字符串
tmps.Free;
exesql(str);
end;
until findnext(fs)<>0 ;
sysutils.findclose(fs);
application.MessageBox('数据导入完毕','成功',MB_ok);
end;
我的这个过程是分别执行工程目录下的所有.txt文件中的sql语句
当文本里的sql语句没有错误时,运行正常,我故意将第一个txt文件的其中一个sql语句改错来测试
然后设置断点单步执行,发现第一个事务出错以后回滚三次就自动直接执行到application.MessageBox('数据导入完毕','成功',MB_ok);然后就退出了,以后的txt文件都不再执行了,而我是想让如果导入第一个txt文件出错以后,回滚五次,如果还出现错误就给个提示以后直接执行下面的txt文件,先不管这次的导入,帮我看看怎么解决?
var I:integer;
begin
i:=0;
Fado.BeginTrans;
if i=3 then
begin
application.MessageBox('该次数据导入出现错误已达5次,请检查!','导入失败',MB_ok);
exit;
end;
try
Fado.Execute(str);
Fado.CommitTrans;
except
Fado.RollbackTrans; end;
end;procedure Tservertransaction.exealltxt;
var
fs: TsearchRec;
tmps:TStringlist;
str,fpath :widestring;
begin
fpath :=ExtractFiledir(Application.Exename);
if findfirst(fpath+'\*.txt',faAnyFile,fs)<>0 then
begin
Application.MessageBox('没有数据文件!','错误',MB_ICONERROR);
exit;
end;
repeat
if (fs.name<>'.') and (fs.name<>'..') then
if((fs.Attr and faDirectory)=faDirectory) then
exeAlltxt
else begin
tmps:=TStringList.Create;
tmps.LoadFromFile(fpath+'\'+fs.name);
str :=listtostr(tmps);//listtostr是我自定义的函数,是将stringlist里的数 据 入到一个字符串
tmps.Free;
exesql(str);
end;
until findnext(fs)<>0 ;
sysutils.findclose(fs);
application.MessageBox('数据导入完毕','成功',MB_ok);
end;
我的这个过程是分别执行工程目录下的所有.txt文件中的sql语句
当文本里的sql语句没有错误时,运行正常,我故意将第一个txt文件的其中一个sql语句改错来测试
然后设置断点单步执行,发现第一个事务出错以后回滚三次就自动直接执行到application.MessageBox('数据导入完毕','成功',MB_ok);然后就退出了,以后的txt文件都不再执行了,而我是想让如果导入第一个txt文件出错以后,回滚五次,如果还出现错误就给个提示以后直接执行下面的txt文件,先不管这次的导入,帮我看看怎么解决?
解决方案 »
- delphi下怎么编程控制显示器屏幕亮度
- 如何在SQL语句中表达edit1.text的值?
- 如何捕捉得到 WebBrowser 执行页面中的js脚本window.close() 的事件??
- 请教大家:如何向一个二维图像数组添加泊松噪声?
- 关于toolbar的问题
- dbexpress调用存储过程的返回值--急
- 如何将客户端access数据库中的表A的数据插入到服务器端SQL Server数据库中的表B中?
- 请问borland自己为delphi开发的那个内存泄露检查工具叫什么名字?
- 问一个服务程序方面的问题?
- 请问有什么书上讲了关于D5中嵌套汇编???
- 消息句柄的作用?
- 怎样改变Memo中某一行字体或某一行的颜色?
var I:integer;
begin
i:=0;
Fado.BeginTrans;
if i=3 then
begin
application.MessageBox('该次数据导入出现错误已达5次,请检查!','导入失败',MB_ok);
if fado.istrans... then Fado.RollbackTrans; //开了一定要关,要不下次就不行
exit;
end;
try
Fado.Execute(str);
Fado.CommitTrans;
except
Fado.RollbackTrans; end;
end;
try
Fado.BeginTrans;
Fado.Execute(str);
Fado.CommitTrans;
except
Fado.RollbackTrans;是不是事务回滚次数大于3次就自己退出
try Fado.Execute(str);
Fado.CommitTrans;
except
Fado.RollbackTrans;
end;