with qry7 do
                begin
                  close;
                  SQL.Add('update stockpile set 代用计数=代用计数+:a where 部品品番=:b and convert(char(7),结存日期,121)=convert(char(7),dateadd(mm,-1,getdate()),121)');
                  Parameters.ParamByName('b').Value:=Trim(cxLookupComboBox3.Text);
                  Parameters.ParamByName('a').Value:=(pyjc-dy);
                  ExecSQL;
                end;
               //更新前 代用计数=200,现在:a计算结果=18,在更新后应该是218,但现在结果是18.请指教教了.

解决方案 »

  1.   

    with qry7 do
    begin
      close;
      SQL.Clear;
      ...
    end;
      

  2.   

    試試把以下語句用showmessage(sql.text)打印出來看看代用計數的值到底是多少
        
    with qry7 do
                    begin
                      close;
                      sql.clear;
                      SQL.Add('update stockpile set 代用计数=代用计数+:a where 部品品番=:b and convert(char(7),结存日期,121)=convert(char(7),dateadd(mm,-1,getdate()),121)');
                      Parameters.ParamByName('b').Value:=Trim(cxLookupComboBox3.Text);
                      Parameters.ParamByName('a').Value:=(pyjc-dy);
                      showmessage(sql.text);
                      ExecSQL;
                    end;
      

  3.   

    參考之
    if DataSet = nil then Exit;
    with (DataSet as TADOQuery) do
    begin
        SQL.Clear;
        SQL.Text := ' UPDATE table_daylog SET [Date] = :p_date, [Style] = :p_style, ' +
                    ' [Area] = :p_area, [Content] = :p_content, [Fee] = :p_fee ' +
                    ' WHERE [Id]=:p_id';
        Parameters.ParamByName('p_id').Value := FId;
        Parameters.ParamByName('p_date').Value := FDate;
        Parameters.ParamByname('p_style').Value := FStyle;
        Parameters.ParamByName('p_area').Value := FArea;
        Parameters.ParamByName('p_content').Value := Content;
        Parameters.ParamByName('p_fee').Value := FFee;
        try
          ShowMessage(SQL.Text);
          ExecSQL;
        finally
          Close;
        end;
    end;
      

  4.   

    笨的要命,掉了sql.clear;谢谢各位了.