在将ACCESS数据填入到stringgrid表格中时出现如上提示ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Text:='select 编码,名称,规格,单位,单价,数量,金额,性质 from smxdl where 编号='''+DBgrid1.Fields[11].AsString+'''';
ADOQuery2.Open; if ADOQuery2.RecordCount >0 then
Groupbox6.Enabled:=true;
stringgridcreat;
with ADoQuery2 do
begin
StringGrid1.RowCount:=ADoQuery2.RecordCount;
StringGrid1.ColCount:=ADoQuery2.Fields.Count;
ppt:=1;
while not Eof do
begin
for ttp:=1 to StringGrid1.ColCount-1 do
stringgrid1.Cells[0,ttp]:=inttostr(ttp);
StringGrid1.Cells[ttp,ppt]:=Fields[ttp].AsString;
Inc(ppt);
ADoQuery2.Next;
end;
end;
代码如上
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Text:='select 编码,名称,规格,单位,单价,数量,金额,性质 from smxdl where 编号='''+DBgrid1.Fields[11].AsString+'''';
ADOQuery2.Open; if ADOQuery2.RecordCount >0 then
Groupbox6.Enabled:=true;
stringgridcreat;
with ADoQuery2 do
begin
StringGrid1.RowCount:=ADoQuery2.RecordCount;
StringGrid1.ColCount:=ADoQuery2.Fields.Count;
ppt:=1;
while not Eof do
begin
for ttp:=1 to StringGrid1.ColCount-1 do
stringgrid1.Cells[0,ttp]:=inttostr(ttp);
StringGrid1.Cells[ttp,ppt]:=Fields[ttp].AsString;
Inc(ppt);
ADoQuery2.Next;
end;
end;
代码如上
解决方案 »
- 一个字符串显示在某个控件里,想给字符串里的某字符加下划线,可以吗?
- 高分提问!!!!关于SOCKET问题,服务器端口正在监听,但是TELNET不到
- delphi提问
- 有关于面向对象的一个问题。请大家看看
- 用savedialog对话框保存文件时怎样防止有同名文件被覆盖?
- 如何得到打印机canvas上的内容?????????????????
- SQL功力很深的朋友进来看一下。
- 怎样才能把图片变小呀?在线等。。。
- 用逗号分隔所取得文件的大小_______在线等待,高分相送
- excel 能不能一次把整个Sheet设为某号大小的字
- 寻找Rave Reports 8.0的下载地址
- [表格控件]在D7的Activex控件组里有一个TF1Book表格控件,有人了解吗?
StringGrid1.ColCount:=ADoQuery2.Fields.Count +1;
都 多加1 再试试嘛
这里的-1不要,刚好8个
while not Eof do
begin
for ttp:=1 to StringGrid1.ColCount-1 do
begin
stringgrid1.Cells[0,ppt]:=inttostr(ppt); //序号替代编码,不显示编码
StringGrid1.Cells[ttp,ppt]:=Fields[ttp].AsString; //显示编码后数据
end;
Inc(ppt);
Next;
end;
你整个for语句循环体都写错了 我楼上也正解