Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160

    Unanswered: Best / Easier Way to import From DBF to SQL

    I get a dbf file to upload about twice and each file changes its structure. I am trying to make a vb app to import the dbf to sql with easy for the user. The user will choose the path and filename of the dbf and choose the database name that will be in sql server.

    What is the best or easiest way to import a dbf file to sql 2000.

    I was thinking 4 ways, but not sure how to do them 100%/

    1 - Search all columns and data lengths on the dbf then create a table in sql and then try a select into thing or something

    2 - Make a stored procedure imports dbf (or any format) to sql without alot of coding. (if alot of coding oh well)

    3 - Something with BCP ???

    4 - any way you cna think of please let me know.

    I seen some code that imports sqldb to sqldb but not from an external db.

    thnx
    Last edited by vextout; 06-15-03 at 12:03.
    Beyond Limitation

  2. #2
    Join Date
    Jan 2003
    Location
    New York
    Posts
    160

    I GOT IT - for all who need it

    i got this to work after about a week and a half

    Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strSQL As String
    conn.Open "DSN=***;uid=***;pwd=***"

    'Select names from dbf file and insert into a new table

    strSQL = "select * into " & txtSQLTableName.Text & " from OpenRowset('MSDASQL', 'Driver={Microsoft dBase Driver (*.dbf)};" & _
    "DefaultDir=" & dirSD.Path & ";','select * from " & File1.FileName & "')"
    rs.Open strSQL, conn, adOpenDynamic, adLockOptimistic
    Beyond Limitation

Posting Permissions

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