注册 登录
编程论坛 Delphi论坛

希望大家知道一下sttringgrid的问题

yuutian 发布于 2010-11-03 17:25, 537 次点击
我将数据库中的数据读入到stringgrid中,
   然而stringgrid中显示的数据有的正确,有的乱码,只显示全都是一样的值
           下面是我的程序代码
恳请高手,大家指导一下
var i,j:integer;
begin
     adoquery2.Close;
     adoquery2.SQL.Clear;
     adoquery2.SQL.add('select calibrationID,coef0,coef1,coef2,coef3 from calibration');
     adoquery2.Open;
     stringgrid2.RowCount:=adoquery2.RecordCount;
     stringgrid2.ColCount:=adoquery2.Fields.Count;

begin
     for i:=0 to stringgrid2.ColCount-1 do
begin
     for j:=0 to stringgrid2.RowCount-1 do
begin
     stringgrid2.Cells[i+1,j+1]:=adoquery2.Fields[i].value;
end;
adoquery2.Next;
end;
end;
end;
2 回复
#2
xu20002010-11-03 20:22

value是变体。很可能乱码的,用DBGrid不行吗?
#3
yuutian2010-11-04 10:41
很感谢回复。
1