473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access and VB

Does anyone know how to programatically set a password for an Access
Database, preferably in ADO? Thanks! - Chris
Nov 21 '05 #1
5 1987
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
13
by: Simon Bailey | last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have a very simplified knowledge of databases overall. I would very much appreciate a (simplifed) message explaining the advantages...
0
by: Frederick Noronha \(FN\) | last post by:
---------- Forwarded message ---------- Solutions to Everyday User Interface and Programming Problems O'Reilly Releases "Access Cookbook, Second Edition" Sebastopol, CA--Neither reference book...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.