帮我看看代码:
procedure Tfrm_input_zg.BitBtn1Click(Sender: TObject);
Var
i:Integer;
begin
ADOQuery1.Open;
if DBGrid1.SelectedRows.Count>0 then
begin
for i:=0 to DBGrid1.SelectedRows.Count+1 do
begin
if ((DBGrid1.Fields[0].AsString<>Null) and (DBGrid1.Fields[1].AsString<>Null)
and (DBGrid1.Fields[2].AsFloat<>0)and (DBGrid1.Fields[8].AsDateTime<>null)) then
begin
ADOQuery1.Append ;
ADOQuery1.Fields[1].AsString:=DBGrid1.Fields[1].AsString;
ADOQuery1.Fields[2].AsString:=DBGrid1.Fields[2].AsString;
ADOQuery1.Fields[3].AsFloat:=DBGrid1.Fields[3].AsFloat;
ADOQuery1.Fields[5].AsFloat:=DBGrid1.Fields[4].AsFloat;
ADOQuery1.Fields[4].AsFloat:=DBGrid1.Fields[5].AsFloat;
ADOQuery1.Fields[6].AsFloat:=DBGrid1.Fields[6].AsFloat;
ADOQuery1.Fields[7].AsFloat:=DBGrid1.Fields[7].AsFloat;
ADOQuery1.Fields[8].AsDateTime:=DBgrid1.Fields[8].AsDateTime;
ADOQuery1.Post;
MessageBox(0,'输入成功','成功',MB_OK);
end
else
begin
MessageBox(0,'编号,姓名与基本工资不能为空,请输入','错误',MB_OK);
Break;
end
end
end
else
MessageBox(0,'请输入数据','错误',MB_OK);
end;
在里面输入数据后,就是追加不进去,说没输入数据。DBGrid1已经设置了dgEditing
为true;各位大虾帮我改一下好吗?