+ -
当前位置:首页 → 问答吧 → Delphi field not found 求解

Delphi field not found 求解

时间:2011-10-02

来源:互联网

最近做项目需要监测用户表空间中数据的变化情况,但是写了一个小函数出错,希望高手帮助解答!
  with qry_log DO
  begin 
  close;
  sql.clear;
  sql.add('select name as 表名 from sysobjects where xtype=''U'' order by name')
  open;
  xls=creatoleobject('Excel.Application');  
  i=3
while not eof do
  begin 
  xls.cells[i,1]:=FieldByName('表名').asstring;
//就在这边程序报错了 
qry_log:filed '表名' not found 
 

作者: wangxiaowen1988   发布时间: 2011-10-02

Delphi(Pascal) code

  with qry_log DO
  begin  
    close;
    sql.clear;
    sql.add('select name as 表名 from sysobjects where xtype=''U'' order by name')
    open;
    xls=creatoleobject('Excel.Application');   
    i:=3;//这里少了冒号、分号
    while not eof do
    begin  
      xls.cells[i,1]:=FieldByName('name').asstring;//括号内应该是字段名,而不是表名

作者: gzzai   发布时间: 2011-10-03