求dbgird一列之和的带吗,但他不能计算,运行后出问题,有无改进的方法
procedure tform1.button1click(send:tobject)
var
sum1:real;
s:string;
book1:tbook;
begin
sum1:=0.00;
book1:=table1.getbook;
table1.disablecontrols;
table1.first;
while not table1.eof do
 begin
 sum1:=sum1+table1.fieldbyname('mingzi').value;
 table1.next;
 end;
table1.gotobook(book1);
table1.freebook(book1);
table1.enablecontrols;
str(sum1:8:2,s);
editdbedit1.text:=s;
end;