Results 1 to 4 of 4

Thread: Change Password in Access Datbase

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    Change Password in Access Datbase

    I'm using Vb 2005 and can't seem to get the datbase password to chnage. I found some code to change the password but they are for earlier versions of vb. I have tried this but it doesn't work.

    VB Code:
    1. Dim conDatabase As OleDb.OleDbConnection = New OleDb.OleDbConnection
    2.        
    3. conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Users.mdb;Jet OLEDB:New Database Password=a"
    4.  
    5. conDatabase.Open()

    After I check the file there is no password for it. Any ideas.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Change Password in Access Datbase

    I'd change it manually and move on unless your project provides users this feature
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    Re: Change Password in Access Datbase

    OK i got it to work but I had to use ADODB like this:

    VB Code:
    1. Dim objConn As ADODB.Connection = New ADODB.Connection
    2.  
    3.         With objConn
    4.             .Mode = 12
    5.             .Provider = "Microsoft.Jet.OLEDB.4.0"
    6.             .Open("Data Source=G:\Users.mdb;Jet OLEDB:Database Password=a")
    7.  
    8.             .Execute("ALTER DATABASE PASSWORD b a;")
    9.         End With

    But I'd rather use OLEDB so I don't have to add another dll. I use this code

    VB Code:
    1. Dim conDatabase As OleDb.OleDbConnection = New OleDb.OleDbConnection
    2.         Dim cmdCommand As OleDb.OleDbCommand
    3.  
    4.         conDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Users.mdb;Jet OLEDB:Database Password=b;Jet OLEDB:Database Locking Mode=12"
    5.         conDatabase.Open()
    6.  
    7.         cmdCommand = conDatabase.CreateCommand
    8.  
    9.         cmdCommand.CommandText = "ALTER DATABASE PASSWORD a b;"
    10.  
    11.         cmdCommand.ExecuteScalar()

    But I get an error on execute scalar:
    "Cannot change password on a shared open database."

    Any help would be great to get it working on OLEDB otherwise Ill just have to add the ADO DLL.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    18

    Re: Change Password in Access Datbase

    WOW looks like a glitch in the [Highlight=VB] handler all the are really : D

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