Click to See Complete Forum and Search --> : How to Open a Password Protected MDB thru Data control


Shella
October 29th, 1999, 05:06 PM
Hi
I've set a paasword for a MDB (MS Access created Database), but I don't know how to set the password as well for the Data Control bound to the Database, in DESIGN TIME. Which property of Data Control is actually used to set the password (During Design-Time) in order to gain access to a password-protected MDB during run-time ? I don't want to use DAO to open the database and then assign it to the data control, coz it's quite troublesome and tedious to do so. Thanks in advance, sincerely

czimmerman
October 29th, 1999, 06:51 PM
Assuming you're using DAO data control, I believe you'd set the connect property to something like the following, after specifying the path of the database.

"pwd=thepassword"

Or you can specify the path in the connect property as well:

"C:\Mydatabase;pwd=thepassword"

At least this is how I think it should work; never done it this way myself.

October 31st, 1999, 07:02 AM
First of all check what you have in DatabaseName property of DC. If you used Open Dialog to choose the database, probably you have the path only without DB name. For example if your database is "C:\MyData\MyDB\MyTestDB.mdb" VB will set it to "C:\MyData\MyDB", so you have to add "\MyTestDB.mdb" manually. This is the most common reason of problem. After that you need to type in Connect Property ;pwd=mypassword. Now RecordSource property is available without any error messages. This works only with Access 97 DB format. If you have to use for some reason an intrinsic DC with Access 2000 DB, you need to insert DAO recordset object between DC and DB like this:

Dim db as Database
Dim Wrkspc as WorkSpaces
Dim strPass as string
Dim DBName as string
Dim rsMyRecordset as Recordset
Dim strSQL as string

strPass = ";pwd=PASSWORD"
strSQL = "SELECT * FROM MyTable"
DBName="C:\.....\MyDB.mdb"
set Wkspc=Workspaces(0)
set db=Wkspc.OpenDatabase(DBName, false, false, strPass)
set rsRecordset = db.OpenRecordset(strSQL, dbOpenDynaset)
set Data1.Recordset=rsRecordset




HTH
Vlad

Shella
October 31st, 1999, 09:37 AM
Hi
Thank You All very much, the problem had been solved, b4 that I got an error meesgae like couldn't find ISAM driver, but now it has been solved, coz the Connect property of datacontrol doesn't recognize "Access;pwd=password" or "DatabasePathName;pwd=password", just type in ";pwd=Password" will do, no wonder I got errors... Thanks anyway.