PRB: "Run-Time Error 3000" Error Message When You Use DSN-Less Connection to Connect to Visual FoxPro Table Through DAO (285345)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q285345

SYMPTOMS

When you use a DSN-less connection to connect to a Visual FoxPro free table through Data Access Objects (DAO), you may receive the following error message:
Run-time error '3000':
Reserved error (-7778); there is no message for this error.

RESOLUTION

To use a DSN-less connection with a Visual FoxPro free table, you must create an Open Database Connectivity (ODBC) workspace. For sample code, refer to the "More Information" section.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open a new Standard EXE project in Visual Basic.
  2. Place a CommandButton control on the form.
  3. Add the following code to the Command1_Click event:
    Dim dbCurrentDB As DAO.Database
    Dim rsTmp As Recordset
    Dim sConnect$, sDatabaseName$, sTable$, i%
    Dim wk As Workspace
            
    sTable = "select * from employees"   ' Modify select to use your Visual FoxPro table.
    ' Modify SourceDB to correctly reflect the path (and path only) of your 
    ' Visual FoxPro .dbf file. Do not include the file name.
    sConnect = "ODBC;SourceType=DBF;" _
    & "SourceDB=c:\TestDir\dataDir\;" _
    & "Driver={Microsoft Visual FoxPro Driver}"
        
    ' Uncomment the following two lines of code to resolve this error.
    ' Set wk = DBEngine.CreateWorkspace("", "admin", "", dbUseODBC)
    ' Set dbCurrentDB = wk.OpenDatabase("", False, False, sConnect)
         
    ' Comment the following line to resolve this error.
    Set dbCurrentDB = DBEngine.OpenDatabase("", False, False, sConnect) ' Fails here.
    
    Set rsTmp = dbCurrentDB.OpenRecordset(sTable, dbOpenSnapshot)
    For i = 0 To rsTmp.Fields.Count - 1
        Debug.Print rsTmp.Fields(i).Name & " | ";
    Next
    Debug.Print ""
    rsTmp.Close
    dbCurrentDB.Close
    Set rsTmp = Nothing
    Set dbCurrentDB = Nothing
    					
  4. Modify SourceDB to correctly reflect the path of your Visual FoxPro .dbf file. The comments indicate where you must make the changes.

    NOTE: Only type the path to the .dbf file; do not type the file name.
  5. Click the command button to run the code. Notice that you receive the above-mentioned error message.

    RESOLUTION

  6. To resolve this problem, create a workspace and successfully open a connection to the database. To do this, uncomment the following two lines
    ' Uncomment the following two lines of code to resolve this error.
    ' Set wk = DBEngine.CreateWorkspace("", "admin", "", dbUseODBC)
    ' Set dbCurrentDB = wk.OpenDatabase("", False, False, sConnect)
    						
    and comment the following line:
    ' Comment the following line to resolve this error.
    Set dbCurrentDB = DBEngine.OpenDatabase("", False, False, sConnect) ' Fails here.
    					
  7. Click the command button to run the code. Notice that the Immediate window displays the data, and you do not receive the error message.

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

212886 ACC2000: Using File DSN to Import or Link a FoxPro ODBC Data Source Causes Reserved Error -7778

190663 PRB: Opening an ODBC Database Inside a Jet Workspace Hangs VB

209953 ACC2000: How to Use the OpenDatabase Method to Open Password-Protected Databases


Modification Type:MajorLast Reviewed:12/30/2001
Keywords:kbDSupport kbJET kbprb KB285345