ADOTable1.last;
ADOTable1.first;
iCount := ADOTable1.recordcout;

解决方案 »

  1.   

    前面是否有Adotable1.Open或Adotable1.Active := True或在设计是便把Active属性设为True
      

  2.   

    procedure TForm_Kinds.FormCreate(Sender: TObject);
    var a:integer;
    begin
      for a:=1 to Form1.ADOTable1.RecordCount do
      begin
        ListBox1.Items[a-1]:='xyz';
      end;
    end;
      

  3.   

    什么时候用的?这段代码最好不能放在FormCreate()
      

  4.   

    但程序执行到 for a:=1 to Form1.ADOTable1.RecordCount do 就出错,
    错误信息为:access violation at address 004cc3d5 in module 'project1.exe' read of address ffffff
      

  5.   

    Form1是哪来的?开始创建了吗?
      

  6.   

    哦,打错了,是
    procedure TForm_Kinds.FormCreate(Sender: TObject);
    var a:integer;
    begin
      for a:=1 to Form_Kinds.ADOTable1.RecordCount do
      begin
        ListBox1.Items[a-1]:='xyz';
      end;
    end;
      

  7.   

    recordcount 就是有问题,如果要得到记录数,你可以:
    var
    i:integer; 
    with query1 do
     begin
      close;
      requestlive:=false;
      sql.clear;
      sql.add(' select count(*) from table1  ');
      open;
      i:=fields[0].asintger;
     end;
    i的值就是该表的记录数
      
      

  8.   

    你的ADOTable1 控件在 Form_Kinds 上是不能这么用的控件还没创建当然会出
    access violation at address 004cc3d5 in module 'project1.exe' read of address ffffff
    的错误。
    如果一定要这么用,再建立一个 DataModul 把ADOTable1 放在那里,将其创建语句放在Form_Kinds 创建前就可以了。
      

  9.   

    就一句行了,setcount忘了,查查。