我有以下代码用于更新数据库中的表,此代码用于使用zeosdblib查询组件在bds 2006中工作,但现在它在delphi xe2中不起作用。任何人都可以告诉我我哪里出错了。谢谢
procedure TGoodsReceivedForm.btnCategorizeClick(Sender: TObject);
var
TempCatTotal : Extended;
nCatogory : string;
begin
TempCatTotal := 0;
zroqryExpcat.Open;
with zroqryExpcat do
begin
first;
while not Eof do
begin
zqrySumCategory.Close;
zqrySumCategory.SQL.Clear;
zqrySumCategory.SQL.Add('select costcategory,packcost,sum(qty)*packcost as pamount');
zqrySumCategory.SQL.Add('from pitems');
zqrySumCategory.SQL.Add('where costcategory=:costcategory and orderno=:orderno');
zqrySumCategory.SQL.Add('group by costcategory,packcost');
zqrySumCategory.Params[0].AsString := zroqryExpcat.FieldByName('Description').Value;
zqrySumCategory.Params[1].AsString := NewPurchaseOrderForm.OrderNumber.Caption ;
zqrySumCategory.Open;
zqrySumCategory.First;
TempCatTotal := 0;
while not zqrySumCategory.eof do
begin
TempCatTotal := TempCatTotal+zqrySumCategory.FieldByName('pamount').AsFloat;
zqrySumCategory.Next;
end;
if TempCatTotal > 0 then
begin
zqryInsertExpense.Close;
zqryInsertExpense.Params[0].AsString := NewPurchaseOrderForm.OrderNumber.Caption ;
zqryInsertExpense.Params[1].AsString := zqrySumCategory.Params[0].AsString ;
zqryInsertExpense.Params[2].AsCurrency := TempCatTotal;
zqryInsertExpense.Params[3].Asinteger := zroqryExpcat.FieldByName('gl_account_no').Value;
zqryInsertExpense.Params[4].AsDate := ReceivedDate.Date;
zqryInsertExpense.ExecSQL;
zqryInsertExpense.Close;
end;
next;
end;
end;
zqryListExpenseCat.Close;
zqryListExpenseCat.Params[0].Value := NewPurchaseOrderForm.OrderNumber.Caption;
zqryListExpenseCat.Open;
end;
答案 0 :(得分:0)
您在行中缺少'
:
zqryInsertExpense.Params[3].Asinteger := zroqryExpcat.FieldByName (gl_account_no').Value;
在FieldByName附近(。你确定你正确地粘贴了这段代码。