关于query的提交

Delphi78 2003-10-09 03:43:09
为什么我的query组件在ApplyUpdates时出现stack overflow?(以前很正常,后来改了代码就不行了,查了半天也没看出端倪)
cacheupdates为true,第一次正常,第二次添加记录时就溢出了
...全文
62 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
NetG 2003-12-05
  • 打赏
  • 举报
回复
可能看不明白?俺就看得???
Delphi78 2003-10-09
  • 打赏
  • 举报
回复
???
怎么每次贴上代码后就没人回贴了?
Delphi78 2003-10-09
  • 打赏
  • 举报
回复
我没改动的时侯没有进行commit也行,改动后加了commit也不行
怀疑是query没有正常释放,程序在运行几次后就不能再运行了,说内存不足
代码写的很烂:

procedure TFrm_DJWH_CHDWH.BTN_AddNoClick(Sender: TObject);
var
_KHBH:string;
_No:integer;
begin
//判断返回结果集不为空时(即存在现有单号),客户编号是否为空
if (not DM.Query_CHDWH.IsEmpty) and ((LKCBB_KHBH.Text=' ') or (LKCBB_KHBH.Text='')) then
begin
MessageDlg('客户编号不能为空,请选择客户编号!',mtInformation,[mbOK],0);
exit;
end;
with DM.Query_CHDWH do
begin
//判断单号是否为空,即判断是否为新增单号
if IsEmpty or (RecordCount<1) then
begin
//Get_TempBill过程生成临时单号
Get_TempBill;
Temp_Bill:=_DH;
DM.Query_Temp.Close;
//得到初始序号
_No:=1;
//客户编号不能为空,所以赋值为空格
_KHBH:=' ';
Close;
SQL.Clear;
SQL.Add('Select * from billaffirm where Ba_billnum='''+_DH+''' order by Ba_no');
RequestLive:=true;
Open;
end
else
begin
//从第一条到最后一条记录进行逐行检查
First;
while not Eof do
begin
if FieldByName('Ba_cmcode').AsString='' then
begin
MessageDlg('客户编号不能为空',mtInformation,[mbOK],0);
LKCBB_KHBH.SetFocus;
Exit;
end;
if FieldByName('Ba_Pdcode1').AsString='' then
begin
MessageDlg('产品编号不能为空',mtInformation,[mbOK],0);
Exit;
end;
if (FieldByName('Ba_PdNum').AsString='') or
(FieldByName('Ba_PdNum').AsInteger=0) then
begin
MessageDlg('产品数量不能为空',mtInformation,[mbOK],0);
Exit;
end;
Next;
end; // end while
_DH:=FieldByName('Ba_billnum').AsString;
//这里得到单号的最大序号
Last;
_No:=FieldByName('Ba_no').AsInteger+1;
_KHBH:=FieldByName('Ba_cmcode').AsString;
end;// end if else
Insert;
Edit;
//以下字段均不允许为空,所以要赋默认值
//单号
FieldByName('Ba_billnum').AsString:=_DH;
//序号
FieldByName('Ba_no').AsInteger:=_No;

... ...

//客户编号
FieldByName('Ba_cmcode').AsString:=_KHBH;
//制单时间
FieldByName('Ba_maketime').AsDateTime:=now;
Post;
ApplyUpdates;
Close;
RequestLive:=true;
Open;
Locate('Ba_no',_No,[]);
end;
end;

procedure TFrm_DJWH_CHDWH.Get_TempBill;
begin
//这里控制临时单号的形成,比如取得最小值-1(10000-1)
DM.Query_Temp.Close;
DM.Query_Temp.SQL.Clear;
if KHGL_Caption.Caption='发货单维护' then
DM.Query_Temp.SQL.Text:='Select MIN(CONVERT(int,SUBSTRING(Ba_billnum,4,10))) as MinNum from billaffirm where Ba_billnum like ''__F%'''
else if KHGL_Caption.Caption='退货单维护' then
DM.Query_Temp.SQL.Text:='Select MIN(CONVERT(int,SUBSTRING(Ba_billnum,4,10))) as MinNum from billaffirm where Ba_billnum like ''__X%''';
DM.Query_Temp.Open;
//如果取得的单号后5位的最小值≥10000则取9999
if DM.Query_Temp.FieldByName('MinNum').AsInteger>=10000 then
_DH:='YYF'+IntToStr(9999)
else
_DH:='YYF'+IntToStr(DM.Query_Temp.FieldByName('MinNum').AsInteger-1);
DM.Query_Temp.Close;
end;
idilent 2003-10-09
  • 打赏
  • 举报
回复
更新完毕有没有commit?
sailer_shi 2003-10-09
  • 打赏
  • 举报
回复
代码看看呀
angle097113 2003-10-09
  • 打赏
  • 举报
回复
没有代码怎么看呀
把改动的代码贴出来吧

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧