how to detect access db has password or not?

i like to know how can i check access database which i going to open do have password or not using vb?
cindafuzzyAsked:
Who is Participating?
 
MarineConnect With a Mentor Commented:
This is how you can do it with DAO.

Dim db As Database
Dim ws As WorkSpace
Dim rst As Recordset
Set ws = DBEngine.WorkSpaces(0)
Set db = ws.OpenDatabase _
("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _
False, False, "MS Access;PWD=northwind")
Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
       
0
 
MarineCommented:
Maybe there is a way but if not then you can make an error handling routine. WHere you would say that password is required.
0
 
cindafuzzyAuthor Commented:
Adjusted points from 50 to 55
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
cindafuzzyAuthor Commented:
i mean the databases is itself is protected with password (ms access can do this)
0
 
MarineCommented:
if your access database is password protected then this is how you can connect to it.
Where it says UID enter your user name and pwd is your password.

Public Sub Con()
On Error GoTo err_con
Dim sCon As String
sCon = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=sample.mdb;" & _
"DefaultDir=" & App.Path & _
";Uid=Val;Pwd=Val;"
cnAcct.Open sCon
Exit Sub
err_con:
    MsgBox Err.Description
    Err.Clear
End Sub
0
 
sharmonCommented:
Access 2000 or 97?

Shannon
0
 
MarineCommented:
You haven't mentioned if you were using ADO OR DAO. This method shows you how to do it in ADO with Access 2000
0
 
MarineCommented:
Check this link out it has examples of how this done with both Ado and Dao.

http://msdn.microsoft.com/library/techart/daotoadoupdate_topic4.htm

Good Luck.
0
 
ayieCommented:
i just want to check the database is password protected or not. marine solution is all right, but is there any other way, without try to connect and get error raised coz' of invalid password?
0
 
cindafuzzyAuthor Commented:
yup, what ayie said is what i want? do you have any better solution marine?
0
 
MarineCommented:
Hmm, a C ? You should have not given a grade at all then. What was with this C i think you got good answer for your question. Not fare man.
0
 
cindafuzzyAuthor Commented:
yup... your  answer is good enough, but i'm just looking for better answer. i hate to say this but i have already tried out your solution before i post the question. anyway it is better for you to feel thankful since i'm just ingore your answer and let the EE decide for delete pending the question. :). no heart feelling friends... maybe you can answer my next question... see you then....
0
 
cindafuzzyAuthor Commented:
anyway, i do have Cs for my answer here... even in my exam.
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.