各位,谁知道ADOTABLE的FINDFIRST得用法,比如要查找一个字段“NO"='1'的记录,如何用?谢谢!

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);var
      sr: TSearchRec;
      FileAttrs: Integer;
    begin
      StringGrid1.RowCount := 1;
      if CheckBox1.Checked then
        FileAttrs := faReadOnly
      else
        FileAttrs := 0;
      if CheckBox2.Checked then
        FileAttrs := FileAttrs + faHidden;
      if CheckBox3.Checked then
        FileAttrs := FileAttrs + faSysFile;
      if CheckBox4.Checked then
        FileAttrs := FileAttrs + faVolumeID;
      if CheckBox5.Checked then    FileAttrs := FileAttrs + faDirectory;
      if CheckBox6.Checked then
        FileAttrs := FileAttrs + faArchive;
      if CheckBox7.Checked then    FileAttrs := FileAttrs + faAnyFile;  if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then  begin
        with StringGrid1 do
        begin
          if (sr.Attr and FileAttrs) = sr.Attr then
          begin
            Cells[1,RowCount-1] := sr.Name;
            Cells[2,RowCount-1] := IntToStr(sr.Size);
          end;
          while FindNext(sr) = 0 do
          begin
            if (sr.Attr and FileAttrs) = sr.Attr then
            begin
            RowCount := RowCount + 1;
            Cells[1, RowCount-1] := sr.Name;        Cells[2, RowCount-1] := IntToStr(sr.Size);
            end;
          end;
          FindClose(sr);
        end;
      end;
    end;
      

  2.   

    TDataSet.FindFirstImplements a virtual method for positioning the cursor on the first record in a filtered dataset.function FindFirst: Boolean;DescriptionThis function returns False, indicating that the cursor was not successfully repositioned. Descendant classes override FindFirst to position the cursor on the first record of the dataset, honoring any filters that are in effect. FindFirst should return True if the cursor is successfully repositioned.帮助里写得很清楚了,
    在一个过滤后的数据集里来返回当前CURSOR的位置状态,,
      

  3.   

    我建议定位方法:Locate 我是这么实现的。具体用法看帮助吧。我就不列出来了。