我在dbgrid里面输入多行记录,为什么总是保存第一行的数据,循环到第二次的时候我show出来显示插入的值都是空值,第二行以后都没有保存进去。显示的都是为空值,求代码(以下是我写的保存记录)。我用的是dbedit。
问题二,为什么我给dbedit赋值 的时候有显示出来,当我用鼠标点击dbedit的时候值就没有了。如何解决。谢谢。
for I := 0 to DBGrideh1.FieldCount-1 do // Iterate
begin
sqltemp1:=sqltemp1+'['+DBGrideh1.Fields[i].FullName+'],';
sqltemp:=sqltemp+'['+DBGrideh1.Fields[i].FullName+'] varchar(1000),';
end; // for
sqltemp1:=Copy(sqltemp1,1,Length(sqltemp1)-1);
sqltemp:=Copy(sqltemp,1,Length(sqltemp)-1);
while not ado_zd.Eof do
begin
with ADO_ZD do
begin
sqltemp2:='';
for I := 0 to ado_zd.FieldCount - 1 do
begin
sqltemp2:=sqltemp2+''''+ado_zd.Fields[i].AsString+''',';
end;
sqltemp2:=Copy(sqltemp2,1,Length(sqltemp2)-1);
Close;
SQL.Clear;
SQL.Add('insert into ZDTABLE('+sqltemp1+') ');
SQL.Add('values ('+''+''+sqltemp2+')');
showmessage(sql.Text );
ExecSQL;
end;
dm_f.adoquery2.Next;
end;
问题二,为什么我给dbedit赋值 的时候有显示出来,当我用鼠标点击dbedit的时候值就没有了。如何解决。谢谢。
for I := 0 to DBGrideh1.FieldCount-1 do // Iterate
begin
sqltemp1:=sqltemp1+'['+DBGrideh1.Fields[i].FullName+'],';
sqltemp:=sqltemp+'['+DBGrideh1.Fields[i].FullName+'] varchar(1000),';
end; // for
sqltemp1:=Copy(sqltemp1,1,Length(sqltemp1)-1);
sqltemp:=Copy(sqltemp,1,Length(sqltemp)-1);
while not ado_zd.Eof do
begin
with ADO_ZD do
begin
sqltemp2:='';
for I := 0 to ado_zd.FieldCount - 1 do
begin
sqltemp2:=sqltemp2+''''+ado_zd.Fields[i].AsString+''',';
end;
sqltemp2:=Copy(sqltemp2,1,Length(sqltemp2)-1);
Close;
SQL.Clear;
SQL.Add('insert into ZDTABLE('+sqltemp1+') ');
SQL.Add('values ('+''+''+sqltemp2+')');
showmessage(sql.Text );
ExecSQL;
end;
dm_f.adoquery2.Next;
end;
