By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

Access and VB

P: n/a
Does anyone know how to programatically set a password for an Access
Database, preferably in ADO? Thanks! - Chris
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Chris,

Maybe you find it here

Access Automate
http://support.microsoft.com/default...EN-US;317113#7

I hope this helps a little bit?

Cor
Nov 21 '05 #2

P: n/a
Hi Chris,

This code will set a password to a previously unprotected Access database:

Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection
With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Mode = adModeShareExclusive
.Open
End With

cnData.Execute "ALTER DATABASE PASSWORD mynewpassword NULL"

Regards

Gerard O'Donnell

"Chris Huddle" wrote:
Does anyone know how to programatically set a password for an Access
Database, preferably in ADO? Thanks! - Chris

Nov 21 '05 #3

P: n/a
Great code..I needed something like that. Next question, how do you open an
Access database that is password protected>

"Gerard O'Donnell" wrote:
Hi Chris,

This code will set a password to a previously unprotected Access database:

Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection
With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Mode = adModeShareExclusive
.Open
End With

cnData.Execute "ALTER DATABASE PASSWORD mynewpassword NULL"

Regards

Gerard O'Donnell

"Chris Huddle" wrote:
Does anyone know how to programatically set a password for an Access
Database, preferably in ADO? Thanks! - Chris

Nov 21 '05 #4

P: n/a
Hi Dennis,

To open a password protected Access database you've got to include the
Password in the Properties collection of the ADO connection.

Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection

With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Properties("Jet OLEDB:Database Password") = "existingpassword"
.Mode = adModeShareExclusive
.Open
End With

Regards,

Gerard O'Donnell

"Dennis" wrote:
Great code..I needed something like that. Next question, how do you open an
Access database that is password protected>

"Gerard O'Donnell" wrote:
Hi Chris,

This code will set a password to a previously unprotected Access database:

Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection
With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Mode = adModeShareExclusive
.Open
End With

cnData.Execute "ALTER DATABASE PASSWORD mynewpassword NULL"

Regards

Gerard O'Donnell

"Chris Huddle" wrote:
Does anyone know how to programatically set a password for an Access
Database, preferably in ADO? Thanks! - Chris

Nov 21 '05 #5

P: n/a
Thanks. I wasn't sure of the syntax. This will help me a lot in what I'm
working on.

"Gerard O'Donnell" wrote:
Hi Dennis,

To open a password protected Access database you've got to include the
Password in the Properties collection of the ADO connection.

Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection

With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Properties("Jet OLEDB:Database Password") = "existingpassword"
.Mode = adModeShareExclusive
.Open
End With

Regards,

Gerard O'Donnell

"Dennis" wrote:
Great code..I needed something like that. Next question, how do you open an
Access database that is password protected>

"Gerard O'Donnell" wrote:
Hi Chris,

This code will set a password to a previously unprotected Access database:

Dim cnData As ADODB.Connection
Set cnData = New ADODB.Connection
With cnData
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=c:\mydatabase.mdb"
.Mode = adModeShareExclusive
.Open
End With

cnData.Execute "ALTER DATABASE PASSWORD mynewpassword NULL"

Regards

Gerard O'Donnell

"Chris Huddle" wrote:

> Does anyone know how to programatically set a password for an Access
> Database, preferably in ADO? Thanks! - Chris
>
>
>

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.