Syntax of ;" & "password=opps"

I just add a password line and now this does not work.  Just need

;" & "password=opps"
 What would be the right syntax?

Any help would greatly be appreciated!


Public Sub OpenADO()
    Dim dbpath As String
   
    '  dbpath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb"
   
    dbpath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb;" & "password=opps"
    Set conn = New ADODB.Connection
    With conn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Open dbpath
    End With
    Set rsShippers = New ADODB.Recordset
    With rsShippers
        .Open "Shippers", conn, adOpenDynamic, adLockOptimistic, adCmdTable
        Cells(2, 2).Value = .Fields(1).Value
        Cells(3, 2).Value = .Fields(2).Value
    End With
   
End Sub
Public Sub CloseADO()
    rsShippers.Close
    Set rsShippers = Nothing
    conn.Close
    Set conn = Nothing
    Cells(2, 2).Value = ""
    Cells(3, 2).Value = ""
End Sub
ca1358Asked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
dbpath = "Data Source=C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb;Jet OLEDB:Database Password=opps;"
0
 
Éric MoreauSenior .Net ConsultantCommented:
Hi ca1358,

The syntax is for a connection string in ADO is:
"Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"

Cheers!
0
 
Bob LambersonSoftware EngineerCommented:
ca1358,
>     dbpath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb;"
> & "password=opps"
Try
dbpath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb " & "password='opps'"

Bob
0
 
ca1358Author Commented:
dbpath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb " & "password='opps'"

tried this but got an error" Could not find installable ISAM"

Not sure how to incorpate this statement


"Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;"

Any other suggestions would greatly be appreciated!


0
 
ca1358Author Commented:
Thank you!!!!!!!!!!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.