CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5

    Connect to Access 2000

    I am trying to connect a VB front end to an Access 2000 backend and am getting the following error: -2147467259(80004005) [Microsoft][ODBC Microsoft Access Drivers] could not find file '(unknown)'
    Does anyone have any ideas? Thanks for any help. Here is my code.

    Public Sub OpenConnection()
    'On Error GoTo Err_Checker

    Set cnDB = New ADODB.Connection

    cnDB.ConnectionString = _
    "Driver={Microsoft Access Driver (*.mdb)};" & _
    "Dbq=C:\MMI\Kettle\" & _
    "KettleDatabse.mdb"

    cnDB.Open

    'Load the main form
    frmMain.Show

    Exit_Checker:
    Exit Sub

    Err_Checker:
    MsgBox "OpenConnection" & vbCrLf & Err.Number & " - " & Err.Description
    Resume Exit_Checker

    End Sub


  2. #2
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5

    Re: Connect to Access 2000

    I figured it out. Just in case anyone else wants to know. This code seems to work.

    Option Explicit
    Public cnDB As adodb.Connection
    Public Sub OpenConnection()
    'On Error GoTo Err_Checker
    Dim AccessConnect As String
    Set cnDB = New adodb.Connection

    AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _
    "Dbq=KettleDatabase.mdb;" & _
    "DefaultDir=C:\MMI\Kettle;" & _
    "Uid=Admin;Pwd=;"
    cnDB.ConnectionString = AccessConnect
    cnDB.Open

    'Load the main form
    frmMain.Show

    Exit_Checker:
    Exit Sub

    Err_Checker:
    MsgBox "OpenConnection" & vbCrLf & Err.Number & " - " & Err.Description
    Resume Exit_Checker

    End Sub



  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Connect to Access 2000

    Use the following connection string

    sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & DBNAME & _
    ";Persist Security Info=False"

    cn.Open sConn

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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