query1.first;
while not query1.eof do
begin
  for i:=0 to query1.Fields.count-1 do
  begin
    ListBox1.Items.Add();//
  end;
  query1.Next;
end;

解决方案 »

  1.   

    query1.sql.SaveToFile(filename);这样可以吗?filename由你自己去指定。。
      

  2.   

    query1.sql.SaveToFile(filename);这样可以吗?filename由你自己去指定。。
      

  3.   

    我不是这个意思,我是指把一个数据库表存按一定的格式村为txt文件
    我现在正在写该函数,如果谁有现成的,借来一用,谢谢
      

  4.   

    我来问一下
    那么如何把一个query 中的内容转存成Execl文件?
      

  5.   

    我不是这个意思,我是指把一个数据库表存按一定的格式村为txt文件
    把txt文件转化为表的时候要忙烦一点,我现在正在写该函数
    如果谁有现成的,借来一用,谢谢
      

  6.   

    1、把一个query 中的内容转换成txt文件的函数应该很容易呀:
      就象上面的,自己写一个就是了。
    query1.first;
    while not query1.eof do
    begin
    yourstr:='';
      for i:=0 to query1.Fields.count-1 do
      begin
       yourstr:=query1.Fields[i].asstring+';'
        //2你的写文件处理。
      end;
      query1.Next;
    end;2、txt文件建议用TFileStream.(大文档)
    大概用的着的地方:
      fnewlog := TFileStream.Create(outfileName, fmCreate);
      flog := TFileStream.Create(infileName.Text, fmOpenRead);
    //下一行:
      buf[0] := #13; buf[1] := #10;
      flog.Position 
      flog.size
        fnewlog.Write(yourstr, length(yourstr));
    记得要:yourstr:=yourstr+#
      Application.ProcessMessages;
    还记得要:
      flog.free;
    3、text to datebase 除了和上面的反向以外主要就是一个格式化字符串的问题:
    给你一个例子:
    unction SplitString(const source,ch:string):tstringlist;
    var
     temp:string;
     i:integer;
    begin
     result:=tstringlist.Create;
     temp:=source;
     i:=pos(ch,source);
     while i<>0 do
     begin
       result.Add(copy(temp,0,i-1));
       delete(temp,1,i);
       i:=pos(ch,temp);
     end;
     result.Add(temp);
    end;
    调用:
    s:=splitstring('afsdfsdaaa|bbfdsfsdb|ccc','|');
    for i:=0 to s.Count-1 do
     b:=b+s.Strings[i]+#13;
    showmessage(b);
    s.free;