在进行完update程序就关闭了.数据已经更新,以下是源码
procedure TForm1.Button2Click(Sender: TObject);
var get_date,csid:string;
    l_avail,l_lqconsum,l_wfconsum,l_yfconsum,l_savail,l_sumavail:single;
    year:integer;
    bl:single;
    querybox1:TQuery;
begin
    if (edit1.text='') or (strtofloat(edit1.text)<30000) then
    begin
      showmessage('返还累计金额不能小于30000');
    end;
    if edit1.text='' then
      begin
       showmessage('请输入返还金额');
       end
    else
      begin
        querybox1:=TQuery.Create(nil);
        with querybox1 do
        get_date:=datetostr(date);
         l_avail:=strtofloat(edit5.text);
         l_lqconsum:=strtofloat(edit1.text);
         csid:=edit3.Text;
         bl :=strtofloat(edit2.text);
      end;
    if csid='' then
      begin
       showmessage('请选择会员')
      end
    else
      begin
         close;
         querybox1.DatabaseName:='ww';
         querybox1.SQL.clear;
         querybox1.SQL.Add('update cs_zzk set j_wfconsum=j_wfconsum-:l_lqconsum ,j_yfconsum=j_yfconsum+:l_lqconsum,f_avail=:l_avail,f_consum=f_consum+:l_avail');
         querybox1.SQL.Add('where cs_id=:csid');
         querybox1.params[0].asfloat:=l_lqconsum;
         querybox1.params[1].asfloat:=l_lqconsum;
         querybox1.params[2].asfloat:=l_avail;
         querybox1.params[3].asfloat:=l_avail;
         querybox1.params[4].asstring:=csid;
         try
         querybox1.ExecSQL;
         except
         close;
         Free;
         queryBox1 := nil;
         exit;
         end;
      end;
end;

解决方案 »

  1.   

    写程序最为忌讳这样了:      begin
             close;  //试问你的这个Close是窗口的Close还是Querybox1的Close;
             querybox1.DatabaseName:='ww';
             querybox1.SQL.clear;
      

  2.   

    你的Close对象好像搞错了吧,你的程序是关闭窗口的Close。
    还有如下写法有时也忌讳
     
    with query1,Query2 do
    begin
     Close;//是两个都要操作吗?
     SQL.Clear;
    ...
    end.
    仅此例子,不要效仿。
     
     
      

  3.   

    你最少应该写上注释吧!CLOSE是什么的!
      

  4.   

    不知道,不过你自己用单步运行看一下到哪里退出,不就很明白了吗??shift+F7