我的程序运行后,是对数据库操作,经常会出现这样的问题:当前一两次执行操作正常后,再执行一次时,程序会突然退出并且没有任何提示信息,真的很烦人,请大仙门帮帮忙
程序调试没有问题,也能运行,只是在运行时,有时会突然退出,特别是当对数据库频繁的操作时就更容易退出,有什么办法能解决吗?能否用ADO解决?我现在用的是ODBC
大家有没有出现过这种情况?如果有,怎么解决的?
例如:
var
result:boolean;
begin
try
result:=true;
if (product_id.Text='')or(config.Text='') or (cpu.Text='')or(mem.Text='')or(hd.Text='')or(display.Text='') or (cd.Text='') or (fd.Text='') then
begin
showmessage('料号或配置和CPU、内存、硬盘、显示屏、光驱、软驱!');
result:=false;
end; if result then
if config.Text=old_config.Text then
begin
showmessage('新配置和原配置相同,不能修改');
result:=false;
end; if result then
with Qy_productid do
begin
close;
sql.Clear;
sql.Add(' update turnoff_id set config=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_actualstate set config=:c_fg ,capacity=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_config set config=:c_fg where config=:old_cfg');
sql.Add(' update turnoff_joinbill set capacity=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_outbill set capacity=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_table set capacity=:c_fg where product_id=:p_id');
sql.Add(' update arrange_bill set config=:c_fg where turnoff_id=:p_id');
parambyname('p_id').AsString:=product_id.Text;
parambyname('c_fg').AsString:=config.Text;
parambyname('old_cfg').AsString:=old_config.Text;
if not prepared then prepare;
execsql;
showmessage('[ '+product_id.text+' ]配置修改成功');
product_id.Text:='';
product_name2.Text:='';
old_config.Text:='';
end;
except
showmessage('网络或系统错误');
end;
程序调试没有问题,也能运行,只是在运行时,有时会突然退出,特别是当对数据库频繁的操作时就更容易退出,有什么办法能解决吗?能否用ADO解决?我现在用的是ODBC
大家有没有出现过这种情况?如果有,怎么解决的?
例如:
var
result:boolean;
begin
try
result:=true;
if (product_id.Text='')or(config.Text='') or (cpu.Text='')or(mem.Text='')or(hd.Text='')or(display.Text='') or (cd.Text='') or (fd.Text='') then
begin
showmessage('料号或配置和CPU、内存、硬盘、显示屏、光驱、软驱!');
result:=false;
end; if result then
if config.Text=old_config.Text then
begin
showmessage('新配置和原配置相同,不能修改');
result:=false;
end; if result then
with Qy_productid do
begin
close;
sql.Clear;
sql.Add(' update turnoff_id set config=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_actualstate set config=:c_fg ,capacity=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_config set config=:c_fg where config=:old_cfg');
sql.Add(' update turnoff_joinbill set capacity=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_outbill set capacity=:c_fg where product_id=:p_id');
sql.Add(' update turnoff_table set capacity=:c_fg where product_id=:p_id');
sql.Add(' update arrange_bill set config=:c_fg where turnoff_id=:p_id');
parambyname('p_id').AsString:=product_id.Text;
parambyname('c_fg').AsString:=config.Text;
parambyname('old_cfg').AsString:=old_config.Text;
if not prepared then prepare;
execsql;
showmessage('[ '+product_id.text+' ]配置修改成功');
product_id.Text:='';
product_name2.Text:='';
old_config.Text:='';
end;
except
showmessage('网络或系统错误');
end;
解决方案 »
- 调研,让事实说话:超过35岁的程序员,你现在干什么?
- 有关数据备份的
- 已Create的MDI子窗体激活?
- 管家婆中的窗体怎么扩大后里面的内容会全部显示?
- 重载和多态问题!欢迎讨论(补分帖)
- 请教怎么访问数据库一条记录的某个字段?
- 在Dll中创建一个TFrame,然后在第二个程序中使用,为什么第二程序关闭时有很多的错误?
- 圣诞了, BCB 水师 操演 ,来此 祝 弟兄们 快乐。
- 如何在窗口的formcreate中停止窗口的创建?
- 谁能告诉我如何将回车键传送到form中的webbrowser控件中去啊?
- HELP!我想找一些工具栏上用的那种小图标,常用的那种,别处怎么都是32*32的呀,哪里有16*16的?
- 请问如何将一个窗体嵌入另一个窗体的client区?
try
execsql;
except
showmessage('出错了');
end;
showmessage('[ '+product_id.text+' ]配置修改成功');
如何用form.update 和form.free
form.free 是在from.close 事件之前调用还是之后调用?
谢谢