escsqlstr:=format('select * from sk_fpls where inday >=''%s'' and inday <=''%s'' ',[sdate1,sdate2]);
      query2.Close;
      query2.SQL.Clear;
      query2.SQL.Add(escsqlstr);
      query2.ExecSQL;
      query2.Open;
      query3.Close;
      if query2.RecordCount<>0 then
      begin
        query2.First;
        for i:=1 to query2.RecordCount do
        begin
          fphm:=query2.fieldbyname('fphm').asstring;
          SqlIns2:=format('select fpdm from sk_fpcode where qshm <= ''%s'' and jzhm >= ''%s'' ',[fphm,fphm]);
          query3.close;
          query3.sql.clear;
          query3.sql.add(sqlins2);
          query3.execsql;
          query3.open;
          fpdm:=query3.fieldbyname('fpdm').asstring;
          escsqlstr:=format('insert into InvoiceWasteBook(rq,fpdm,Fphm,Ztbz) values(''%s'',''%s'',''%s'',''%s'')',[rq,fpdm,fphm,zt]);
            with query1 do
            begin
              close;
              sql.Clear;
              sql.Add(escsqlstr);
              execsql;
            end;
            query1.Close;
            query3.Close;
          if not query2.Eof then query2.Next;
        end;当记录很多的时候,就报错:太频繁的打开表SK_FPCODE。有什么好的解决方法?谢谢!

解决方案 »

  1.   

    Use Filter to specify a dataset filter. When filtering is applied to a dataset, only those records that meet a filter抯 conditions are available to an application. Filter contains the string that describes the filter condition. For example, the following filter condition displays only those records where the State field is 'CA' or 'MA':State = 'CA' or State = 'MA'To filter strings bases on partial comparisons, use an asterisk as a wildcard. For example:State = 'M*'
      

  2.   

    DescriptionUse the Filter property to restrict the rows in the dataset to those that meet the filter conditions.  The syntax for Filter is the same as the search condition that appears after a WHERE clause in a Select statment.  For example, to view only those records where the value in the Country field contains 'France' or 'Fiji':Country = 'France' or Country = 'Fiji'You can use standard SQL wildcards such as percent (%) and underscore (_) in the condition when you use the LIKE operator.  The following filter condition retrieves all Countries begining with 'F':Country LIKE 'F%'To view rows that have a NULL value in the Country column and Contact_Name is not NULL, use the IS operator:Country is NULL and Contact_Name is not NULLYou can also use complex expression in filter clauses this one thatretrieves rows with Country values that use Francs as currency.  Thisstatement gets countries with currencies as 'BFranc', 'SFranc', and'FFranc'Country IN (SELECT Country from Country where Currency = '_Franc')
      

  3.   

    Filtered:=false;
    Filter:=format('qshm <= ''%s'' and jzhm >= ''%s'' ',[fphm,fphm]);
    Filtered:=true;