Solved

change access 2003 password using ADO and visual basic

Posted on 2004-10-18
12
325 Views
Last Modified: 2008-02-26
Hello,

I need to change number of databases and set it the same password.
However , I dont know how to set password using ADO, i'm using access 2003
here is my code and it doesnt work:

            Dim myDbase As ADODB.Connection
            Set myDbase = New ADODB.Connection
            myDbase.Mode = adModeShareExclusive
            myDbase.IsolationLevel = adXactIsolated

        myDbase.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" _
                  & dbpath & " ; DefaultDir=" & App.Path & ";" & "PWD=" & Oldpass & ";"
        myDbase.Execute "Alter database password " & Oldpass & " " & newdbpass

            myDbase.Close

how can I set a new password for the access 2003 database?


Thanks,
Eyal
0
Comment
Question by:eylkrn
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 12340362
I doubt that you can change the password for an Access database via ADO, as the password IS NOT stored in the MDB, but rather is held in the associated MDW (workgroup file), and as such is not accessible from SQL (or via ADO).

AW
0
 

Author Comment

by:eylkrn
ID: 12340750
is there any other way that I change the password?
or is there any program that does what I need?
There most be a way to write a script that change number of databases
0
 
LVL 5

Expert Comment

by:Hammadian2
ID: 12341272
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 5

Assisted Solution

by:Hammadian2
Hammadian2 earned 100 total points
ID: 12341297
0
 
LVL 26

Assisted Solution

by:Alan Warren
Alan Warren earned 400 total points
ID: 12344467
You can change  a JET database password using the CompactDatabase method of a JRO object.
Your source connect string should contain the original old password.
Your destination connect should contain the new password.


reference: Microsoft Jet and Replication Objects 2.6 Library
Function EncryptDb(strSourceDB As String, _
                     strDestDB As String) As String
   Dim jetEngine          As JRO.jetEngine
   Dim strSourceConnect   As String
   Dim strDestConnect     As String

   ' Build connection strings for SourceConnection and
   ' DestConnection arguments.
   strSourceConnect = "Data Source=" & strSourceDB
   strDestConnect = "Data Source=" & strDestDB & ";" & _
                     "Jet OLEDB:Encrypt Database=True" & ";" & _
                     "Jet OLEDB:Database Password = password"

   Set jetEngine = New JRO.jetEngine

   ' Compact and encrypt the database specified by strSourceDB
   ' to the name and path specified by strDestDB.
   
   jetEngine.CompactDatabase strSourceConnect, strDestConnect

   Set jetEngine = Nothing
End Function

Alan
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 12344484
I like the link posted by Hammadian2, seems better than my attempt - LOL

Alan
0
 
LVL 5

Expert Comment

by:Hammadian2
ID: 12347952
Thanks Alan :)
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 400 total points
ID: 12545264
Hi Venabili,

I like the look of the post by Hammadian2 http:#12341272
Also like mine http:#12344467 

Perhaps a split, unless the author has other plans.

Alan
0
 

Author Comment

by:eylkrn
ID: 12546131
hi Venabili,

dont close it yet..

Eyal
0
 
LVL 20

Expert Comment

by:Venabili
ID: 12583032
eylkrn,

Then please reply to the experts that are trying to help you. We are not mind readers so unless you explain what is wrong with the posted comments, we cannot help more..

Venabili
0
 

Author Comment

by:eylkrn
ID: 12586311
ok, I'm closing this issue because i'm currently working on another project

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question