Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataBase PassWord

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
HI
I use Access and VB
I want to open the database (which has a password)from my Program but each time there is a problem because of the Password
What is the right Syntax?
Thanx
 
Provider=Microsoft.Jet.OLEDB.4.0;Password=pwd;User ID=Bob;Data Source=D:\BOB\SAMPLE.mdb;Persist Security Info=True
 

thanx for your help
but actually it didn't work
maybe the open statment is wrong
Set db1 = ws.opendatabase(path, , , ";pwd")
i would be grateful if you help me
thank you
 
Sorry, the syntax I gave you was for ADO.

I haven't used DAO for years, but I would try something like this:

For Access 97:
Set db1 = ws.opendatabase(path, , , "Access;pwd=mypassword")

For Access 2000:
Set db1 = ws.opendatabase(path, , , "Access 2000;pwd=mypassword")

Good luck.

 
i am so sorry because it didn't work again
i tried alot of syntaxs
really don't know what to do???????????
 
Dim myDB AS DAO.Database
Set myDB = DAO.OpenDatabase("C:\myData\myMDB.MDB",False,False,";pwd=123456")
 
You have to be clear if it a Database Password ( which I guess it is) or a Security password

Here's how to do it in ADO

Dim cnn as ADODB.Connection
strPass = "DeadParrot"
strDB = "C:\Work\MyWind.mdb"
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = strPass
.Open "Data Source=" & strDB
End With

Here's how to do it in DAO

Dim db as DAO.Database
strPass = "DeadParrot"
strDB = "C:\Work\MyWind.mdb"
Set db = DBEngine.Workspaces(0).OpenDatabase _
(strDB, True, True, ";pwd=" & strPass)

These are cut and pasted from working code with the names changed to protect the guilty.
 
Isn't that how it was written above? Bot types of passwords (security and database) work in the example I gave. The user ID has to be added also if it differes from Admin. Admin is the default that is always used regardless if security (with a user ID) is used or not.
 
barnstorm
Thanks for your offer to help
But it was clear that my Question is about DAO & Database
Password i didn't mention ODBC or any kind of connections
the wronge thing i did is not defining Database as DAO
that is the thing (CCLINT) notified me about.
and you wrote the same syntax thanx
(CCLINT)
thanx again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top