Results 1 to 4 of 4

Thread: Problems connecting to Access database

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    44

    Resolved Problems connecting to Access database

    I am having a wierd error when trying to connect to a database. I have been using the same code all the time to connect but still get error .

    "[Microsoft][ODBC Driver Manager], data source name not found and no default driver specified"

    Below is my code:
    Set oConn = New ADODB.Connection
    Set ors = New ADODB.Recordset
    cs = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    & "Data Source=" & App.Path & "\Database.mdb"
    'oConn.Mode = adModeReadWrite
    oConn.Open , cs
    ors.Open "tblCategory", cs, adOpenStatic

    I have made sure that my references were corrrect. Can someone give me a hand on what this may be. Thanks in advance.

    oobern
    Last edited by oobern; Feb 4th, 2005 at 07:21 PM.

  2. #2
    New Member Syberius's Avatar
    Join Date
    Feb 2005
    Location
    Dundee, Scotland
    Posts
    9

    Re: Problems connecting to Access database

    This is the connection code I have been using for my database programming in ADO.
    visual basic code: Dim dbFile As String ' Holds the path to the database file
    ' Asign data

    dbFile = App.Path & "\lecture.mdb"
    Set
    adoConnection = New ADODB.Connection
    adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &
    "Data Source=" & dbFile & ";" & "Persist Security Info=False"
    I am not entirely sure if the Persist and Security Info need to be in the string or not but that does apear to work.

    Syberius,
    Last edited by Syberius; Feb 4th, 2005 at 06:52 PM.

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    44

    Resolved Re: Problems connecting to Access database

    Thank you very much. I modified your code and it worked!!!. Between your code and mine there is really no difference from what i can see. But you method works, so i think i will put the whole path and database file to a variable and pass that to the connection string from now on. Thanks again

  4. #4
    New Member Syberius's Avatar
    Join Date
    Feb 2005
    Location
    Dundee, Scotland
    Posts
    9

    Re: Problems connecting to Access database

    It probably has something to do with the string but im no expert on OLE so I cannot say for sure.

    Glad it is working for you.

    Oh, I edited the code above to split the lines, was all on one big line before for some reason.

    Syberius.

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