Results 1 to 3 of 3

Thread: Connecting to Access via ADO

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    I have an app that uses an Access database thru DAO. I want to upgrade it to ADO. I use both a Username and Password for each user. This is how far I've gotten:
    Code:
    Dim DSN As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim strPath$, sql$
    
    With DSN
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Properties("Jet OLEDB:System database") = Trim(PROJ_System_MDW)
        .Properties("Data Source") = Trim(PROJ_DB_PATH) & PROJ_DB_Name
        .Properties("Jet OLEDB:Database Password") = g_sPassword
    '    .Properties("Jet OLEDB:Database Username") = g_sUserName
        .Open
    End With
    Notice the rem'd line. I cannot figure how to pass the username (this is not working). Can anyone help? If I remove the Password line as well, the database opens fine, but I've lost the security aspects. BTW, the "PROJ_" vars are pre-set.

  2. #2
    New Member
    Join Date
    Oct 2000
    Location
    Houston, Texas
    Posts
    11

    Access Db Password Protected

    Opening Access Database Using ADO
    Dim DSN As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim strPath$
    Dim Uid$, PW$

    'Access Version
    UId = "sa"
    PW = "Password"
    strPath = "d:\temp\test.mdb"
    With DSN
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .Open strPath, Uid, PW
    End With
    SQL = "Select * From Table_Name"
    Rs.Open SQL, DSN, adOpenDynamic, adLockOptimistic

    You can do anything you want with this. I usually
    make DSN Global to the whole project, you can then
    use it anywhere.




  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    82
    Thanks, Corby. Works great.

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