Jump to content

Changing Access Database Password


AutoSlip
 Share

Recommended Posts

I can't create a topic in the appropriate section (???), so I try here.

This very simple function change the password of an Ms Access Database (tested with access 2000 and access 2002) using DAO 3.6.

I'm new to AutoIt, so there are no proper error handling or return code (and correct English).

; Example : Define a password on the database
DBChangePassword("E:\base.mdb","","pswd")

; Example : Change the password on the database
DBChangePassword("E:\base.mdb","pswd","new")

; Example : reset the password on the database
DBChangePassword("E:\base.mdb","new","")


;========================================================================================
; Change Access Database Password
; The Database must be close by all others applications, because we have to open it in 
; Exclusive mode
;
; Parameters :
;(1-i.) Complete Path to the database
;(2-i.) Old Password ("" if no password was defined)
;(3-i.) New Password ("" for no password)

; Return     : -
;========================================================================================
Func DBChangePassword($pDBPath, $pOldPswd, $pNewPswd)
    
    ;>) Create the "DB Engine", we must specifie the version
    $dbEng = ObjCreate("DAO.DBEngine.36")
    ;>) Open database in Exclusive mode
    $db = $dbEng.Workspaces(0).OpenDatabase($pDBPath,True, False, ";pwd=" & $pOldPswd)
    ;>) Set the new password
    $db.NewPassword($pOldPswd, $pNewPswd)
    ;>) Close the Database
    $db.Close   
    
EndFunc
Link to comment
Share on other sites

If you were trying to post in the example scripts forum you have to be a full member. Post a little more then you can or you can ask a mod/admin to move it there for you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...