我在ADOQ(连的VFP)中生成了一个数据集,如何把这个数据集保存成VFP格式的DBF文件?就是说我要用ADO +SQL生成新的表,不用循环

解决方案 »

  1.   

    VFP好象也支持sql的,可以用select into吧
      

  2.   

    呵呵,老大,用SELECT INTO我执行了没反应:)
    如果你能通过,请写出全部的PAS文件:)包括ADO的CONNECTIONSTRING
      

  3.   

    //ado创建dbf
    procedure TForm1.Button1Click(Sender: TObject);
    var
     DBPath: String;
    begin
     DBPath:='e:\dfwtest\test7';//你的数据库路径目录;
     ADOConnection1.ConnectionString:='Provider=MSDASQL.1;'
                                      +'Persist Security Info=False;'
                                      +'Extended Properties='
                                      +'"Driver={Microsoft Visual FoxPro Driver};'
                                      +'UID=;'
                                      +'SourceDB='+ DBPath + ';'
                                      +'SourceType=DBF;'
                                      +'Exclusive=No;'
                                      +'BackgroundFetch=Yes;'
                                      +'Collate=Machine;'
                                      +'Null=Yes;'
                                      +'Deleted=Yes;"';
     AdoConnection1.Open;
     AdoQuery1.Sql.Text := 'create table "aaa.dbf" (aaa char(2))';
     //AdoQuery1.Sql.Text := 'create table "ddd.dbf" (aaa char(2)),fff float(3),eee numeric (4,1),torf boolean ,rdate date)';
     AdoQuery1.ExecSql;
    end;
    //ado打开dbf
    procedure TForm1.Button3Click(Sender: TObject);
    var
     DBPath: String;
    begin
     DBPath:='e:\dfwtest\test7';//你的数据库路径;
     ADOConnection1.ConnectionString:='Provider=MSDASQL.1;'
                                      +'Persist Security Info=False;'
                                      +'Extended Properties='
                                      +'"Driver={Microsoft Visual FoxPro Driver};'
                                      +'UID=;'
                                      +'SourceDB='+ DBPath + ';'
                                      +'SourceType=DBF;'
                                      +'Exclusive=No;'
                                      +'BackgroundFetch=Yes;'
                                      +'Collate=Machine;'
                                      +'Null=Yes;'
                                      +'Deleted=Yes;"';
     AdoQuery1.close;
     AdoQuery1.sql.clear;
     AdoQuery1.sql.Text := 'select * from ddd.dbf';
     adoquery1.Open;
    end;
      

  4.   

    if not Table1.Exists then begin
      with Table1 do begin
        { The Table component must not be active }
        Active := False;  
        { First, describe the type of table and give }
        { it a name }
        DatabaseName := 'dbase';
        TableType := ttFoxpro;
        TableName := 'CustInfo';
        { 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 := 'total';
            DataType := ftfloat;
            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 := 'Fldidx1';
            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;
      

  5.   

    老大,创建DBF的我早写过了,可我现在想用SELECT INTO呀,我不想在用户那边装上BDE的东西
      

  6.   

    关键是要把我的数据保存进去,不用BatchMove,但我的数据量大,不大可能用循环来做呀
      

  7.   

    不错,ADO可以支持向文件型数据库的写入功能的.
      

  8.   

    反正我select into;insert into多能通过,但实际上数据库没反应
      

  9.   

    select into [foxpro 6.0;Database=d:\MyDatabase].[abc.dbf] from [SourceTableName]
      

  10.   

    ADOQuery1.Close;
     ADOQuery1.SQL.Clear;
     ADOQuery1.SQL.Add ('select into [foxpro 6.0;Database=d:\temp].[abc.dbf] from test ');
     ADOQuery1.ExecSQL ;
    出错!
    PARAMETER对象被不正确的定义。提供了不一至或不完整的信息
      

  11.   

    'Provider=MSDASQL.1;'
                                      +'Persist Security Info=False;'
                                      +'Extended Properties='
                                      +'"Driver={Microsoft Visual FoxPro Driver};'
                                      +'UID=;'
                                      +'SourceDB='+ DBPath + ';'
                                      +'SourceType=DBF;'
                                      +'Exclusive=No;'
                                      +'Location=clUseClient'
                                      +'BackgroundFetch=no;'
                                      +'Collate=Machine;'
                                      +'Null=Yes;'
                                      +'Deleted=Yes;"';
    不对
      

  12.   

    'Driver={Microsoft Visual FoxPro Driver};UID=;SourceDB='
            + 'd:\zbzkdata\dmdata;'
            +'SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;'
            +'Collate=Machine;Null=Yes;Deleted=yes;'
    这个CONNECTION也一样报错
      

  13.   

    用ADO我只用循环,好象还没找到办法,
    建DBF用Create table "path\filename"