将ado连接数据库 用adoquery 查询出来的dbgrid数据表,怎样导出成dbf文件呢  
各位先谢过了 分不够再加!!
在线等……

解决方案 »

  1.   

    //Access->DBF
    procedure TForm1.Button3Click(Sender: TObject);
    begin
      sSql := 'select * into aaa in ''f:\'' ''dbase 5.0;'' from demo';
      with AccessConnection do
        begin
          Connected := True;
          Execute(sSql);
        end;
    end;
      

  2.   

    那你直接在SQL Server里边导出不是更简单么.
      

  3.   

    你先在磁盘上创建一个dbf文件。再用database组件动态链接好。这样就行了。
      

  4.   

    如果要导出数据到已经生成结构(即现存的)FOXPRO表中,可以直接用下面的SQL语句insert into openrowset('MSDASQL',
    'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\',
    'select * from [aa.DBF]')
    select * from 表说明:
    SourceDB=c:\  指定foxpro表所在的文件夹
    aa.DBF        指定foxpro表的文件名.
      

  5.   

    建个dbf的连接,再创建个空表,然后把数据一条一条插过去!  ——铁笨的方法
      

  6.   

    adoconnection 连接dbf数据库
    procedure TForm1.Button3Click(Sender: TObject);
    begin
      sSql := 'SELECT * into table  FROM Tab1 IN [ODBC]
               [ODBC;Driver=SQL Server;UID=sa;PWD=;Server=127.0.0.1;DataBase=Demo;]';
      with AccessConnection do
        begin
          Connected := True;
          Execute(sSql);
        end;
    end;
    ----------------------------------------------------------------
                 花自飘零水自流,一种相思,两处闲愁。
                   此情无计可消除,才下眉头,又上心头。
    ----------------------------------------------------------------
      

  7.   

    我以前一直这样,建一个空表,将数据写入,或许还有更好的办法,关注。如果dbf没有索引,可以直接创建一个DBF空头,速度还是慢快的。
      

  8.   

    我连接的数据库 是sql
    想通过adoquery 把查询出来的数据导出到dbf文件中
      

  9.   

    1. Create connection to open DBF files
    We can use several providers to open DBF files usind ADODB. Basic way is to use ODBC data source (DSN or DSNless), there is several samples published on web. But how to open DBF files without ODBC? There are two other OLEDB providers, using which you can work with DBF files. One of them is Microsoft.Jet.OLEDB. 
    Key property to work with DBF files is "Extended Properties" - there is no much info about this parameter in documentation. This parameter has similar meaning as connect parameter in DAO OpenDatabase method. First work is to open connection to DBASE IV files:
    Function OpenDBFConn(Path)
    Dim Conn: Set Conn = CreateObject("ADODB.Connection")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Path & ";" & _
    "Extended Properties=""DBASE IV;"";" 
    Set OpenDBFConn = Conn
    End Function2. Other ISAM formats, FoxPro
    "DBASE IV" is one of ISAM format. You can find installed ISAM formats in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\
    registry key. You can use other formats - "dBase 5.0", "Paradox 3.X", "Outlook 9.0" etc. 
    But what about FoxPro files? Microsoft.Jet.OLEDB.4.0 does not support FoxPro 2.0 - 3.0 as ISAM parameter - you cannot see this ISAM engine in Jet\4.0\ISAM Formats lists. You can do some small work around of this feature - import FoxPro ISAM from Jet\3.5 key. Create small .reg file with the next information:REGEDIT4[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\FoxPro 3.0]
    "Engine"="Xbase"
    "ExportFilter"="Microsoft FoxPro 3.0 (*.dbf)"
    "CanLink"=hex:00
    "OneTablePerFile"=hex:01
    "IsamType"=dword:00000000
    "IndexDialog"=hex:00
    "CreateDBOnExport"=hex:00
    "ResultTextExport"="Export data into a Microsoft FoxPro 3.0 file."
    "SupportsLongNames"=hex:00
    Then you can use 
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Path & ";" & _
    "Extended Properties=""FoxPro 3.0;"";" 3. Work with DBF connection
    So, what we can do with the connection? You can use any ODBC statement (Create table, Insert Into, Delete, Select ...). You can address the table using several ways:Select * from Persons 
    Select * from Persons.DBF
    Insert Into Persons#DBF Values (...)
    Delete * from [Persons.DBF] Where ...Create Table [Any Long File Name You Want] As ...
    4. Real VBS samples
    Open DBF connection, create table, insert records, get recordset.
    'Open connection For DBF files In F:\ folder
    Dim DBConn
    Set DBConn = OpenDBFConn("f:\")'Create a new DBF file named Persons.DBF
    DBConn.Execute "Create Table Persons (Name char(50), City char(50), Phone char(20), Zip decimal(5))"'Insert some row To the table
    DBConn.Execute "Insert into Persons Values('Alex P. Nor', 'Mexico','458962146','14589')"'Open recordset from Persons table
    Dim Persons
    Set Persons = DBConn.Execute("Select * from [Persons#DBF]")'Output the recordset In csv format
    Wscript.Echo Persons.GetString(,-1, ", ", vbCrLf)