Import in MSAcces from dBase


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Import in MSAcces from dBase

  1. #1
    Join Date
    Jan 2005
    Location
    Romania
    Posts
    23

    Open a dBase file

    Hi,

    I want to open the dBASE file (.dbf) with VB, and when I try to manipulate (through SQL) the table, I receive a lot of error msg.

    -it's better for me to use Data Control or ADODC? In Data I find reference to dBase, but in ADODC I didn't find...

    My code:

    Dim conexaoDBF As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim sql As String


    conexaoDBF = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & "C:\Documents and Settings\sorin\Coduri VB\Dani\sorin.dbf" & "';Extended Properties=dBASE IV;Mode=Read;Jet OLEDB:database Locking Mode =1"
    Rs.Open "Select * From sorin", conexaoDBF, , , adCmdText

    Set DataGrid1.DataSource = Rs
    ----------------------------------
    but there is an error (3709) and don't work...


    If you have experience in this type of work (dBase with VB), could you give me a solution or some steps in solve my problem? May be it's imposible to do this kind of work...

    Thanks in advance and best regards
    zane
    Last edited by z.s; 05-18-2005 at 07:18 AM.
    zane

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    The connection string is incorrect. Only the location (folder) of the file should be specified as the Data Source and not the filename. The filename should only be referenced in the SQL statement (without the file extension). Change your Data Source to the following:

    Data Source=C:\Documents and Settings\sorin\Coduri VB\Dani;
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Jan 2005
    Location
    Romania
    Posts
    23
    Even if I change Data Source the code don't run well, I receive the same error number...

    I have been trying for 6 hours to open a dBASE file...Now, I have more white hair! the true is that I have not experience in DSN or anything like this...
    zane

  4. #4
    Join Date
    Dec 2003
    Posts
    2,750
    I can't seem to reproduce the error. On which line does the error occur?

    Here is an example that works for me:

    Code:
        Dim cnn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
    
        cnn.CursorLocation = adUseClient
        cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\My Documents\dBase;Extended Properties=dBase IV;"
        
        rs.Open "Select * from Table10", cnn, adOpenStatic, adLockReadOnly
    
        Set DataGrid1.DataSource = rs
    Paul
    ~~~~
    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