Click to See Complete Forum and Search --> : database password
marilyn
Apr 21st, 2000, 02:41 AM
How do I open an access database with a password on it from VB? The DB doesn't have user-level security...just a database password.....
Thanks :)
Mongo
Apr 21st, 2000, 04:16 AM
To open a password-protected Access database using ADO, specify the password with the provider-specific Jet OLEDB:Database Password property by using the Properties collection of the Connection object, or as part of the connection string passed to the Open method of the Connection object. This is the basic MSDN example:
Function OpenProtectedDB(strDBPath As String, strPwd As String)
Dim cnnDB As ADODB.Connection
Set cnnDB = New ADODB.Connection
' Open database for shared, read/write access, and
' specify database password.
With cnnDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = strPwd
.Mode = adModeReadWrite
.Open strDBPath
End With
' Play with database code goes here...
cnnDB.Close
Set cnnDB = Nothing
End Function
FWIW, the OpenProtectedDB proc is available in the modSecurity module in AccessSecurity.mdb in the ODETools\V9\Samples\ODETools\V9\Samples\OPG\Samples\CH18 subfolder on the Office 2000 Developer CD-ROM. Cheers.
smalig
Apr 30th, 2000, 09:16 PM
Data Object example
http://vbcity.com/vbcode/en/click.asp?id=52
DAO example
http://vbcity.com/vbcode/en/click.asp?id=51
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.