Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2006
    Posts
    34

    Unanswered: VB 6 Connecting to Access

    Dear Gurus (and probably even novices)

    I am having trouble connecting to a Database (MS Access) in VB6. The db sits in the same folder as the VB project. I have not even tried to add, update, or delete...just connect.

    I have tried all of the following to connect.

    ------------------------------
    dim ws as workspace
    dim db as database
    dim strConnection as string

    set ws=DBEngine.Workspaces(0)
    let strConnection="ODBC;DSN="& databaseName
    'where databaseName is (1) the path to the database including the name and extension (.mdb) and (2) just the name and extension

    set db=ws.opendatabase("",false,false, strConnection)
    ----------------------------------------------------------

    dim ad as adodb.connection
    set ad=New adodb.connection
    let ad.conectionstring=="ODBC;DSN="& databaseName
    ad.open
    -----------------------------------------------------

    and a few other combinations.

    I get errors everytime.

    are there particular drivers that i am missing? do i need to try DSN-less? etc.

  2. #2
    Join Date
    Feb 2006
    Posts
    34
    ...ohhhh,

    the latest error is:

    "unrecognized database format"



    other errors were
    Error 3151

    Error 3453


    IM010:[Microsoft][ODBC Driver Manager] Data Source Name Too Long
    ' this one was with the full path name
    Last edited by poison_chicken; 09-12-06 at 17:32.

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    If you are going to use a dsn, you have to reference the DSN NAME in the connection string, NOT the database name/path.

    The database name & path are contained WITHIN the DSN.

    Personally, I would recomend using ADO.

    Ref the ADO Tutorial
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  4. #4
    Join Date
    Feb 2006
    Posts
    34
    i don't have permission to read that. (i did register)

Posting Permissions

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