dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to create a new dbf file using ADO in VB6 ?

  1. #1
    Keith Lee Guest

    How to create a new dbf file using ADO in VB6 ?


    hi,
    my mission is to write a vb program which retrieve data
    from SQL Server and store into a new dbf file every week.

    The dbf file is in a table format.
    e.g. Code char(10)
    Name varchar (100)
    Status char(10)

    My problem now is how to create the dbf file using VB.

    TQ in advance.

  2. #2
    Paul Clement Guest

    Re: How to create a new dbf file using ADO in VB6 ?

    On 30 Jan 2001 09:04:47 -0800, "Keith Lee" <kitleeky@hotmail.com> wrote:


    hi,
    my mission is to write a vb program which retrieve data
    from SQL Server and store into a new dbf file every week.

    The dbf file is in a table format.
    e.g. Code char(10)
    Name varchar (100)
    Status char(10)

    My problem now is how to create the dbf file using VB.

    Here is an example that uses ADOX (Microsoft ADO Ext. 2.x for DDL and Security):

    Sub CreatedBaseWithADOX()

    Dim tbl As New ADOX.Table
    Dim cat As New ADOX.Catalog

    cat.ActiveConnection = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\My Documents\dbase;" & _
    "Extended Properties=dBase III;"


    tbl.NAME = "MydBaseIII"
    tbl.Columns.Append "Column1", adInteger
    tbl.Columns.Append "Column2", adInteger
    tbl.Columns.Append "Column3", adVarWChar, 50
    cat.Tables.Append tbl

    End Sub

    Or you can simply export and create the dBase file at the same time. The below example uses Access -
    you would just need to change the connection info (provider) and table name for SQL Server;

    Sub ExportTodBase()

    Dim cnn As New ADODB.Connection
    Dim sqlString As String

    ' Open the Connection
    cnn.Open _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\My Documents\db1.mdb;" & _
    "Jet OLEDB:Engine Type=4"

    sqlString = "SELECT * INTO [dBase IV;DATABASE=C:\My Documents\dBase].[dBaseExport] FROM [Table1]"
    cnn.Execute sqlString

    cnn.Close
    Set cnn = Nothing

    End Sub


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center