Results 1 to 2 of 2

Thread: Changing an mdb password programatically: This snippet works

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Changing an mdb password programatically: This snippet works

    I spent an unusually long time looking for this on the forums. The only responses I found were vague, incomplete, had errors in the snippet, or just plain didn't work. I wanted to post this to maybe keep someone else from having to navigate through all that. One posting came close, but had some typos. I forget the post or the poster, but this is based on his method and it works:

    VB Code:
    1. Public Sub ChangePassword(fileName As String, older As String, newer As String)
    2.    Dim CGPconn As New ADODB.Connection
    3.    Dim strsql As String
    4.    CGPconn.Mode = adModeShareExclusive
    5.    CGPconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    6.               fileName & ";Jet OLEDB:Database Password=" & older
    7.    strsql = "Alter Database Password " & newer & " " & older
    8.    CGPconn.Execute (strsql)
    9.    Set CGPconn = Nothing
    10. End Sub

    You do, of course, need to set a reference to Microsoft Active X Data Objects

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Changing an mdb password programatically: This snippet works

    Moved to the Codebank.


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width