How to Change the Database Password Programmatically?
This tutorial will teach you on how to change the database password of an Access database programmatically using visual basic 6.0.
CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabasePath & ";Persist Security Info=False;Mode=12;Jet OLEDB:Database Password="current password here"
- sqlExecStr = "ALTER Database Password " & txtNewPass & " " & txtOldPass & ";"
- CN.Execute sqlExecStr
Where CN is your database connection variable.
If you use the database before changing the password be sure to close it by adding code like:
Open the database exclusively by adding:
This is very important since you cannot change the password if you did not open it exclusively.