Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: Connecting VB 6.0 to MS Access.

    Hello everybody!

    I'm new to programming, trying to create a simple VB project using MS Access as the backend. I'm having problems connecting to the Access database (which resides on my PC, no server etc.)

    I would like to know what connection string I need to use for connection;
    data source, initial catalog, user id, password (I haven't specified any user id or password for the databse, so I assume these need to be left blank, but just in case..) ole db provider (I guess it Microsoft Jet OLE DB 4.0).

    I know a bit of ADO programming, so basically I'd like to avoid using DAO or something else, but not sure if that's possible while working with Access.

    Thanks in anticipation!

  2. #2
    Join Date
    Nov 2003
    Posts
    267
    DIm adoCN As New ADODB.Connection
    Dim adoRS As ADODB.Recordset

    adoCN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=["Path and Name of DB"];Persist Security Info=False"

    Set adoRS = New ADODB.Recordset
    sStr = "tablename"
    adoRS.Open sStr, adoCN, adOpenDynamic, adLockOptimistic


    S-

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    And here's a good connections reference:

    Able Consulting - ADO Connection String Samples
    http://www.able-consulting.com/ADO_Conn.htm
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  4. #4
    Join Date
    Mar 2004
    Posts
    2
    Thanks everyone for replies!

    I did try that code and I was able to connect to the databse. However, I later added two command buttons for addings and deleting records which are now throwing errors. It says something like- 'VB does not support the object' (it highlights rs.addnew and rs.delete in the code part.

    I have heard that jet providers don't support dynamic cursors, so I tried adopenkeyset instead of adopendynamic, but the same error still comes up. What could be wrong?

  5. #5
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    Make sure, your cursor location is 'client' instead of server.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by n-bonapart-2
    Thanks everyone for replies!

    I did try that code and I was able to connect to the databse. However, I later added two command buttons for addings and deleting records which are now throwing errors. It says something like- 'VB does not support the object' (it highlights rs.addnew and rs.delete in the code part.

    I have heard that jet providers don't support dynamic cursors, so I tried adopenkeyset instead of adopendynamic, but the same error still comes up. What could be wrong?
    Where did you open your connection? Since you have buttons the connection object (and your recordset object) should be at the form level at least ...

Posting Permissions

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