StringGrid1.Cells[i,j]中的i代表列数,j代表行数while not table1.eof do begin j:=0; for i:=0 to m //m=你的数据库字段数-1 StringGrid1.Cells[i,j]:=table1.field(i).value //获得第一条记录的各字段值 j:=j+1; Tale1.Next; end;
while not table1.eof do begin j:=0; for i:=0 to 2 //m=你的数据库字段数-1 StringGrid1.Cells[i,j]:=table1.fields[i].value //获得第一条记录的各字段值 j:=j+1; Tale1.Next; end; 仅录入最后一条记录
j:=0; while not table1.eof do begin for i:=0 to 2 //m=你的数据库字段数-1 StringGrid1.Cells[i,j]:=table1.fields[i].value //获得第一条记录的各字段值 j:=j+1; Tale1.Next; end;
table1.First; j:=0; while not table1.eof do begin for i:=0 to 2 //m=你的数据库字段数-1 StringGrid1.Cells[i,j]:=table1.fields[i].value; //获得第一条记录的各字段值 j:=j+1; Tale1.Next; end;
begin
j:=0;
for i:=0 to m //m=你的数据库字段数-1
StringGrid1.Cells[i,j]:=table1.field(i).value //获得第一条记录的各字段值
j:=j+1;
Tale1.Next;
end;
begin
j:=0;
for i:=0 to 2 //m=你的数据库字段数-1
StringGrid1.Cells[i,j]:=table1.fields[i].value //获得第一条记录的各字段值
j:=j+1;
Tale1.Next;
end;
仅录入最后一条记录
while not table1.eof do
begin
for i:=0 to 2 //m=你的数据库字段数-1
StringGrid1.Cells[i,j]:=table1.fields[i].value //获得第一条记录的各字段值
j:=j+1;
Tale1.Next;
end;
j:=0;
while not table1.eof do
begin
for i:=0 to 2 //m=你的数据库字段数-1
StringGrid1.Cells[i,j]:=table1.fields[i].value; //获得第一条记录的各字段值
j:=j+1;
Tale1.Next;
end;
另,现在没有直接把数据文件直接导入StringGrid的控件,因此只有采用这种逐条导入的办法。
执行后出错
"Could not convert variant of type (Null) into type (String)"
table.field中有空数据造成
"Could not convert variant of type (Null) into type (String)".
怎么办??