把SQL SERVER数据库表中的数据取出来,
追加到文本文档中,再给取出来的数据做上标记(把表ZONG中的最后一个字段Status的值更新为1)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~用ADOQUERY控件.
用下面的语句出错.
开始AdoQuery的SQL为 "SELECT * FROM ZONG ORDER BY ID"procedure TForm1.Button1Click(Sender: TObject);
var
  temp : PChar;
  f:textfile;
  n1:string;
begin  adoquery1.Open;
  while not adoquery1.Eof do
  begin
  edit0.Text:=Trim(adoquery1.Fields[0].AsString);
  edit1.Text:=Trim(adoquery1.Fields[1].AsString);
  edit2.text:=Trim(adoquery1.Fields[2].AsString);
  edit3.Text:=Trim(adoquery1.Fields[3].AsString);
  temp:=SearchCar(pchar(Edit1.Text),pchar(Edit3.Text),pchar(Edit2.Text),1);
  Memo1.Text:=temp;
  n1:=edit0.Text+edit1.Text+edit2.Text+edit3.Text
  adoquery1.SQL.Text:='update zong1 set Status=1 where id="&n1&"';
  adoquery1.ExecSQL;
  AssignFile(f,'d:\Delphi7\bb.txt');
  append(f);
  Writeln(f,temp);
  CloseFile(f);
  adoquery1.Next;
  end;
end;

解决方案 »

  1.   

    adoquery1.Open;
      while not adoquery1.Eof do
      begin
      edit0.Text:=Trim(adoquery1.Fields[0].AsString);
      edit1.Text:=Trim(adoquery1.Fields[1].AsString);
      edit2.text:=Trim(adoquery1.Fields[2].AsString);
      edit3.Text:=Trim(adoquery1.Fields[3].AsString);
      temp:=SearchCar(pchar(Edit1.Text),pchar(Edit3.Text),pchar(Edit2.Text),1);
      Memo1.Text:=temp;
      n1:=edit0.Text+edit1.Text+edit2.Text+edit3.Text
      adoquery1.SQL.Text:='update zong1 set Status=1 where id="&n1&"';
      adoquery1.ExecSQL;
      AssignFile(f,'d:\Delphi7\bb.txt');
      append(f);
      Writeln(f,temp);
      CloseFile(f);
      adoquery1.Next;
      end;同一ADOQUERY 用来遍历, 用来更新,当然问题了中间更新的ADOQuery 用另外一个ADOQuery