ADOQuery.SaveToFile
你不是知道了吗:)

解决方案 »

  1.   

    可我现在想用Query,而不是ADOQuery,该怎么办呢?
      

  2.   

    方法很多。
    你可以在DELPHI中用 记事本,把QUERY的结果写到记事本中保存。
    还可以在DELPHI中用 EXCEL,然后保存。或者用INI文件保存。如果你用的SQL SERVER的话,SQL 的执行工具可以直接保存成你想要的格式。
      

  3.   

    Query1.First;
      sTmp := '';
      for iField := 0 to Query1.FieldCount-1 do
      begin
        sTmp := sTmp + Query1.Fields[iField].FieldName;
        sTmp := sTmp + '  ';
      end;
      sTmp := sTmp + #13+#10;
      while not Query1.Eof  do
      begin
        for iField := 0 to Query1.FieldCount-1 do
        begin
          sTmp := sTmp + Query1.Fields[iField].Value;
        end;
        sTmp := sTmp + #13+#10;
      end;
      Memo1.Lines.Add(sTmp);
      

  4.   

    procedure SaveQuery(tempQuery:TQuery)
    var
      i,j: Integer;
      tempMemo: TMemo;
      tempStr: String;
    begin
      try
        tempMemo := TMemo.Create(nil);
      except
        exit;
      end;
      tempQuery.First;
      for i:=0 to tempQuery.RecordCount-1 do
      begin
        tempStr:='';
        for j:=0 to tempQuery.FieldCount -1 do
        begin
          tempStr := tempStr + ' ' + tempQuery.Fields[j].asString;
        end;
        tempMemo.Lines.add(tempStr);
        tempQuery.Next;
      end;
      tempMemo.Lines.SaveToFile('youText.txt');
      tempMemo.Free;
    end;
      

  5.   

    随手写的,应该能用,没什么难度,你会用吗?
    把有结果的Query给这个过程就可以了
      

  6.   

    我的习惯是,把Query中的数写到Memo中,然后用Memo的功能将他存为文本文件,一切OK!
      

  7.   

    哦!这样我也想到了,我想了解一下是不是它也有类似ADOQuery.SaveToFile的方法而我不知道的,谢谢大家!呵呵……
      

  8.   

    顺便再问一下能不能存成.DBF文件呢?