如何修改delphi自带数据库中表中字段的值
这一段代码没有提示错误但添加到数据库中的记录的值修改不了procedure TForm3.Button1Click(Sender: TObject);
var
log,i:integer;
begin
try
with table1 do
begin
active;
open;
edit;
log:=0;
if edit1.Text=''then
begin
showmessage('请输入完整信息');
exit;
end;
if edit2.Text='' then
begin
showmessage('请输入完整信息');
exit;
end;
for i:=0 to table1.fieldcount-1 do
begin
if table1.Eof=true then
begin
break;
end;
if table1.FieldByName('Goodsno').AsString=edit1.Text then
begin
log:=1;
if table1.FieldByName('Goodsnum').AsInteger>=strtoint(edit2.Text) then
begin
table1.active;
table1.open;
table1.edit;
table1.FieldByName('Goodsnum').AsInteger:=table1.FieldByName('Goodsnum').AsInteger-strtoint(edit2.Text);
table1.Post;
table1.Close;
showmessage('出仓成功!');
exit;
end
else
begin
showmessage('对不起!没有足够的货物');
table1.Close;
exit;
end;
end;
table1.Next;
end;
if log=0 then
begin
showmessage('对不起!没有符合的产品');
table1.Close;
exit;
end;
end;
except;
end;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm3.FormActivate(Sender: TObject);
begin
table1.Active;
table1.Open;
table1.Edit;
end;
end.