Change Password in Access Datbase
I'm using Vb 2005 and can't seem to get the datbase password to chnage. I found some code to change the password but they are for earlier versions of vb. I have tried this but it doesn't work.
VB Code:
Dim conDatabase As OleDb.OleDbConnection = New OleDb.OleDbConnection
conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Users.mdb;Jet OLEDB:New Database Password=a"
conDatabase.Open()
After I check the file there is no password for it. Any ideas. :confused:
Re: Change Password in Access Datbase
I'd change it manually and move on unless your project provides users this feature
Re: Change Password in Access Datbase
OK i got it to work but I had to use ADODB like this:
VB Code:
Dim objConn As ADODB.Connection = New ADODB.Connection
With objConn
.Mode = 12
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open("Data Source=G:\Users.mdb;Jet OLEDB:Database Password=a")
.Execute("ALTER DATABASE PASSWORD b a;")
End With
But I'd rather use OLEDB so I don't have to add another dll. I use this code
VB Code:
Dim conDatabase As OleDb.OleDbConnection = New OleDb.OleDbConnection
Dim cmdCommand As OleDb.OleDbCommand
conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Users.mdb;Jet OLEDB:Database Password=b;Jet OLEDB:Database Locking Mode=12"
conDatabase.Open()
cmdCommand = conDatabase.CreateCommand
cmdCommand.CommandText = "ALTER DATABASE PASSWORD a b;"
cmdCommand.ExecuteScalar()
But I get an error on execute scalar:
"Cannot change password on a shared open database."
Any help would be great to get it working on OLEDB otherwise Ill just have to add the ADO DLL. :cry:
Re: Change Password in Access Datbase
WOW looks like a glitch in the [Highlight=VB] handler all the :D are really : D