CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2001
    Posts
    5

    Export data to a dbf file

    I am running a query that selects some fields from a table and saves the values in another temporary table. The problem is that I want to export this table or the result set to a dbf file and then open it for editing in Microsoft Access. I know that SQL-DMO provides a way of exporting data from one table to another but I haven't seen any examples of exporting data to a dbf file. Is there any way of doing that with the SQL-DMO or SQL-DTS (or any other way)? Any help preferably with examples is welcome.

    Thanks in advance
    George




  2. #2
    Join Date
    Feb 2001
    Posts
    54

    Re: Export data to a dbf file

    Hello George:

    If I understand you correctly, you do it this way. If copy data from Oracle table to Access with this code using ADO:

    Private Sub Command1_Click()
    On Error Resume Next
    Do Until Adodc2.Recordset.EOF
    If Adodc2.Recordset.BOF Then
    Adodc1.Recordset.AddNew
    Adodc1.Recordset.Fields(0).Value = Adodc2.Recordset.Fields(0).Value
    Adodc1.Recordset.Fields(1).Value = Adodc2.Recordset.Fields(1).Value
    Adodc1.Recordset.Fields(2).Value = Adodc2.Recordset.Fields(2).Value
    Adodc2.Recordset.MoveNext
    Else
    Adodc1.Recordset.AddNew
    Adodc1.Recordset.Fields(0).Value = Adodc2.Recordset.Fields(0).Value
    Adodc1.Recordset.Fields(1).Value = Adodc2.Recordset.Fields(1).Value
    Adodc1.Recordset.Fields(2).Value = Adodc2.Recordset.Fields(2).Value
    Adodc2.Recordset.MoveNext
    End If
    Loop
    If Adodc2.Recordset.EOF Then
    Adodc1.Recordset.AddNew
    Adodc1.Recordset.Fields(0).Value = Adodc2.Recordset.Fields(0).Value
    Adodc1.Recordset.Fields(1).Value = Adodc2.Recordset.Fields(1).Value
    Adodc1.Recordset.Fields(2).Value = Adodc2.Recordset.Fields(2).Value
    Adodc2.Recordset.MoveNext
    End If
    End Sub


    Please reply back if this is not what you want


  3. #3
    Join Date
    Jun 2001
    Posts
    5

    Re: Export data to a dbf file

    Basically, I have a table in SQL Server and all I want to do is to export the data of the table to a file with dbf format. The reason I want to do this is because I want to open the file in Access and create a shortcut to the dbf file to allow viewing and editing of the data. This code with the recordsets will work only if the file has been created. The problem is that I don't know how to create this (dbf) file. Any ideas? Thanks for your help in advance.

    George


  4. #4
    Join Date
    Feb 2001
    Posts
    54

    Re: Export data to a dbf file

    Hello George:

    I am sorry I do not know

    Robert


  5. #5
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: Export data to a dbf file

    Every start this procedure you need create dbf file?

    Andy Tower

  6. #6
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: Export data to a dbf file

    Maybe you can use DTS Package?
    In this Package you can create DBF file, export into this file any data from MS SQLServer.

    Andy Tower

  7. #7
    Join Date
    Jun 2001
    Posts
    5

    Re: Export data to a dbf file

    Yes, I think that is the only way. Any examples or sample code that might help?


  8. #8
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: Export data to a dbf file

    You can create DTS in Enterprise Manager.
    1. Create DBF connection to needed catalog
    2. Execute command for this connection "Create table test (test char(10))"
    Comment: this is command create table test and column test in this table
    3. Create connection to SQLServer
    4. Create transformation data task from SQLServer to DBF table

    This is all. If you have any question ask me.

    Andy Tower

  9. #9
    Join Date
    Jun 2001
    Posts
    5

    Re: Export data to a dbf file

    Yes, basically I need to collect some data from one or more tables in SQL (through a query) and save it on a dbf file every time the query is executed. Is there any sample code available that might help?

    thanks


  10. #10
    Join Date
    Jun 2001
    Posts
    5

    Re: Export data to a dbf file

    I know the way to do it through Enterprise Manager but I need to do that in VB programmatically. I am using VB to connect to the server to run the query but I don't know how to export the result set to a dbf file. Any examples of how to do that in VB with DTS or SQL-DMO?

    Thanks


  11. #11
    Join Date
    Jul 2000
    Posts
    110

    Re: Export data to a dbf file

    Try this high performance DBF engine: (VB source code include)
    http://www.banasoft.com/DownLoad/BNxBase.exe


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured