我想在程序里用代码创建本地的 dbf文件用来暂时保存一些数据,delphi里怎么
用代码创建一个 dbf 文件? 要求创建出来的dbf文件能用ADO来操作!    希望高手指点

解决方案 »

  1.   

    帮助里面的:with Table1 do begin
      Active := False;  
      DatabaseName := 'DBDEMOS';
      TableType := ttParadox;
      TableName := 'CustInfo';
      if not Table1.Exists then begin
        { The Table component must not be active }
        { First, describe the type of table and give }
        { it a name }
        { Next, describe the fields in the table }
        with FieldDefs do begin
          Clear;
          with AddFieldDef do begin
            Name := 'Field1';
            DataType := ftInteger;
            Required := True;
          end;
          with AddFieldDef do begin        Name := 'Field2';
            DataType := ftString;
            Size := 30;
          end;
        end;
        { Next, describe any indexes }
        with IndexDefs do begin
          Clear;
          { The 1st index has no name because it is
          { a Paradox primary key }
          with AddIndexDef do begin
            Name := '';
            Fields := 'Field1';
            Options := [ixPrimary];
          end;
          with AddIndexDef do begin        Name := 'Fld2Indx';
            Fields := 'Field2';
            Options := [ixCaseInsensitive];
          end;
        end;
        { Call the CreateTable method to create the table }
        CreateTable;
      end;
    end;
      

  2.   

    http://www.delphibox.com/article.asp?articleid=531
      

  3.   

    ADO操作dbf挺麻烦的,最主要的是完全删除数据的问题(vfp中的Pack)。在BDE中还可以用DbiPackTable实现真正删除,ADO我就不知道了。
      

  4.   

    http://community.csdn.net/Expert/topic/3008/3008997.xml?temp=.300213