我是从 ADOQuery1中循环调出 filestr,让templist记录后保存到一个文件tsl.txt里面
问题出在红色的那行, for i:=0 to aalist.Count -1  do
      begin
      s:=aalist.Strings[i];
      bblist.Add(GetDelimiteredStringN(s,',',3));
      str:=bblist.Strings[i];
         with datam.ADOQuery1 do
          begin
          datam.ADOQuery1.Active:=false;
          datam.ADOQuery1.SQL.Clear;
          datam.ADOQuery1.SQL.Text:=sqlstr1+sqlstr2+#39+str+#39+sqlstr3;
          datam.ADOQuery1.Active:=true;
          end;
          try
            if datam.ADOQuery1.RecordCount>0 then
                begin
                filestr:= datam.ADOQuery1.FieldByName('rh').AsString;
                if filestr='' then filestr:='0';
                templist.Strings[i]:=filestr;
                //writeln(f,filestr);
                end;
          except

解决方案 »

  1.   

    是提示超出templist的索引范围吗?如果是的话就是不存在templist.Strings[i],
    改为templist.add(filestr);
      

  2.   

    能解释一下templist.Strings[i], templist.add(filestr);的区别吗?
      

  3.   

    解释一下你要实现什么功能,或许不需要搞得如此复杂.如果是要把一个记录值写到txt文件中,循环一下,直接writeLN 直接可以,不需要再搞个List出来
      

  4.   

    strings[i]:='xxx'  是指把指定记录赋值
    add 是增加一条新的记录
      

  5.   

    第一,templist没有被创建,当然有可能是控件
    第二.templist.Strings[i]是否存在,如果不存在,访问将出错