是不是第一次查询后第二次查询之前没有交Query关掉?
Query.close;
Query.aql.add('');
Query.open;

解决方案 »

  1.   

    procedure TChxBaseInfoForm.SpeedButton1Click(Sender: TObject);
    var
      SQLStr,SQLAll,Log:String;
      SQLTemp:Pchar;
      arrstr:array[1..13]of String;
      i,l:integer;
      function getsth(CurrEdit:TEdit):boolean;
      begin
        result:=false;
        if CurrEdit.Text<>'' then
          result:=true;
      end;
    begin
      SQLAll:='';
      SQLStr:='SELECT * FROM "YQBaseInfo" WHERE ';
      if RadioGroup1.ItemIndex=1 then Log:='OR' else Log:='AND';
         arrstr[1]:=Cob_bianhao.Text;
      if arrstr[1]<>'' then
         arrstr[1]:='(设备编号='''+arrstr[1]+''')';
         arrstr[2]:=Cob_status.text;
      if arrstr[2]<>'' then
         arrstr[2]:='(现状='''+arrstr[2]+''')';
         arrstr[3]:=Cob_xinghao.text;
      if arrstr[3]<>'' then
         arrstr[3]:='(型号='''+arrstr[3]+''')';
         arrstr[4]:=Cob_gzrq.text;
      if arrstr[4]<>'' then
         arrstr[4]:='(购置日期='''+arrstr[4]+''')';
         arrstr[5]:=Cob_fzwz.text;
      if arrstr[5]<>'' then
         arrstr[5]:='(放置位置='''+arrstr[5]+''')';
         arrstr[6]:=Cob_chandi.Text;
      if arrstr[6]<>'' then
         arrstr[6]:='(产地='''+arrstr[6]+''')';
         arrstr[7]:=Cob_flh.text;
      if arrstr[7]<>'' then
         arrstr[7]:='(分类号='''+arrstr[7]+''')';
         arrstr[8]:=Cob_plant.text;
      if arrstr[8]<>'' then
         arrstr[8]:='(生产厂家='''+arrstr[8]+''')';
         arrstr[9]:=Cob_glry.text;
      if arrstr[9]<>'' then
         arrstr[9]:='(管理人员='''+arrstr[9]+''')';
         arrstr[10]:=Cob_name.text;
      if arrstr[10]<>'' then
         arrstr[10]:='(设备名称='''+arrstr[10]+''')';
      if arrstr[11]<>'' then
         arrstr[11]:='(维修次数='''+Edit_cishu.Text+''')';
      if arrstr[12]<>'' then
         arrstr[12]:='(附件总数='''+Edit_total.Text+''')';
      arrstr[13]:='';
      for i:=1 to 12 do
      begin
        arrstr[13]:=arrstr[13]+arrstr[i];
        if arrstr[i]<>'' then
          SQLAll:=SQLAll+Log+arrstr[i];
      end;
      if arrstr[13]='' then
      begin
        showmessage('没有输入查询条件!请输入具体的查询条件。');
        exit;
      end;  l:=strlen(Pchar(SQLAll));
      GetMem(SQLTemp,l);
      SQLTemp^ := Chr(0);  if SQLAll[1]='O' then
        StrCat(SQLTemp,Pchar(SQLAll)+2);
      if SQLAll[1]='A' then
        StrCat(SQLTemp,Pchar(SQLAll)+3);  SQLStr:=SQLStr+SQLTemp+' ORDER BY 设备编号,设备名称,型号,分类号,购置日期,现状,放置位置,附件总数';
      FreeMem(SQLTemp);
      Application.MessageBox(Pchar(SQLStr),'预查询的SQL语句',MB_OK);  with DataModule1.ADOQuery1 do
      begin
        SQL.Clear;
        SQL.Add(SQLStr);
        ExecSQL;
        Open;  end;
      

  2.   

    with DataModule1.ADOQuery1 do
      begin
        SQL.Clear;
        SQL.Add(SQLStr);
        Open;
      end
      

  3.   

    with DataModule1.ADOQuery1 do
      begin
        active:=false;
        SQL.Clear;
        SQL.Add(SQLStr);
        Open;
      end
      

  4.   

    active:=false;与close不是一样的嘛。