Solved

how to detect access db has password or not?

Posted on 2000-05-06
13
163 Views
Last Modified: 2010-05-02
i like to know how can i check access database which i going to open do have password or not using vb?
0
Comment
Question by:cindafuzzy
13 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2783878
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
 

Author Comment

by:cindafuzzy
ID: 2784017
Adjusted points from 50 to 55
0
 

Author Comment

by:cindafuzzy
ID: 2784018
i mean the databases is itself is protected with password (ms access can do this)
0
 
LVL 6

Expert Comment

by:Marine
ID: 2784085
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
 
LVL 6

Expert Comment

by:sharmon
ID: 2784797
Access 2000 or 97?

Shannon
0
 
LVL 6

Expert Comment

by:Marine
ID: 2784818
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Accepted Solution

by:
Marine earned 55 total points
ID: 2784829
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
 
LVL 6

Expert Comment

by:Marine
ID: 2784830
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
 

Expert Comment

by:ayie
ID: 2785266
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
 

Author Comment

by:cindafuzzy
ID: 2785278
yup, what ayie said is what i want? do you have any better solution marine?
0
 
LVL 6

Expert Comment

by:Marine
ID: 2789054
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
 

Author Comment

by:cindafuzzy
ID: 2789104
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
 

Author Comment

by:cindafuzzy
ID: 2789110
anyway, i do have Cs for my answer here... even in my exam.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now