Solved

change access 2003 password using ADO and visual basic

Posted on 2004-10-18
12
297 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now