msowards
02-15-2012, 02:44 PM
I have a little Access app originally written using .mdb /.mde. It has an option to change the currently assigned password. When I converted to a .accdb format to take advantage of the higher security levels. This option no longer works. The old version ....
Dim dbsDB As DAO.Database
Dim strOpenPwd As String
' Create connection string by using current password.
strOpenPwd = ";pwd=" & OldPswd
' Open database for exclusive access by using current password. To get
' exclusive access, you must set the Options argument to True.
Set dbsDB = OpenDatabase(Name:=DBPath, _
Options:=True, _
ReadOnly:=False, _
Connect:=strOpenPwd)
' Set or change password.
With dbsDB
.NewPassword OldPswd, Pswd2
.Close
End With
...works fine
but this new version causes...
Dim ADO_Cnnct As adodb.Connection, strAlterPassword As String
Set ADO_Cnnct = New adodb.Connection
With ADO_Cnnct
.Mode = adModeShareExclusive
.Provider = "Microsoft.ACE.OLEDB.12.0"
' Use old password to establish connection
.Properties("Jet OLEDB:Database Password") = "OldPswd"
'name current DB
DBPath = [CurrentProject].[FullName]
.Open "Data Source= " & DBPath & ";"
' Execute the SQL statement to change the password.
.Execute (strAlterPassword)
End With
'Clean up
ADO_Cnnct.Close
Set ADO_Cnnct = Nothing
... causes file already inuse message
I'v tried different modes but still get the error message.
Is there a way to change the DB password when using the accdb or accde file format?
Dim dbsDB As DAO.Database
Dim strOpenPwd As String
' Create connection string by using current password.
strOpenPwd = ";pwd=" & OldPswd
' Open database for exclusive access by using current password. To get
' exclusive access, you must set the Options argument to True.
Set dbsDB = OpenDatabase(Name:=DBPath, _
Options:=True, _
ReadOnly:=False, _
Connect:=strOpenPwd)
' Set or change password.
With dbsDB
.NewPassword OldPswd, Pswd2
.Close
End With
...works fine
but this new version causes...
Dim ADO_Cnnct As adodb.Connection, strAlterPassword As String
Set ADO_Cnnct = New adodb.Connection
With ADO_Cnnct
.Mode = adModeShareExclusive
.Provider = "Microsoft.ACE.OLEDB.12.0"
' Use old password to establish connection
.Properties("Jet OLEDB:Database Password") = "OldPswd"
'name current DB
DBPath = [CurrentProject].[FullName]
.Open "Data Source= " & DBPath & ";"
' Execute the SQL statement to change the password.
.Execute (strAlterPassword)
End With
'Clean up
ADO_Cnnct.Close
Set ADO_Cnnct = Nothing
... causes file already inuse message
I'v tried different modes but still get the error message.
Is there a way to change the DB password when using the accdb or accde file format?