Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion mdb Password
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Zuzar Ladkawala  
View profile  
 More options Nov 24 2002, 10:21 pm
Newsgroups: microsoft.public.in.csharp
From: "Zuzar Ladkawala" <zu...@rediffmail.com>
Date: Mon, 25 Nov 2002 08:48:46 +0530
Local: Sun, Nov 24 2002 10:18 pm
Subject: Re: mdb Password
Hi Jassim,
I am unaware if u can check if the password exists in the Access DB or not
but, you can programmatically set, change, or remove a database password by
using the ALTER DATABASE keyword with the following syntax:
ALTER DATABASE PASSWORD NewPassword OldPassword.
Kindly Go through the code below which has 2 methods , the 1st one will
change the password of ur access DB and the 2nd one will change ur existing
password:

1) Private Function CreateDBPassword(ByVal Password As String, _
        ByVal Path As String) As Boolean
    Dim objConn as ADODB.Connection
    Dim strAlterPassword as String
    On Error GoTo CreateDBPassword_Err
    ' Create the SQL string to initialize a database password.
    strAlterPassword = "ALTER DATABASE PASSWORD [Password] NULL;"

    ' Open the unsecured database.
    Set objConn = New ADODB.Connection
    With objConn
        .Mode = adModeShareExclusive
        .Open "Provider=Microsoft.Jet.OLEDB.4.0;Data " & _
            "Source=Path;"

     ' Execute the SQL statement to secure the database.
     .Execute (strAlterPassword)
    End With

    ' Clean up objects.
    objConn.Close
    Set objConn = Nothing

    ' Return true if successful.
    CreateDBPassword = True

CreateDBPassword_Err:
    Msgbox Err.Number & ":" & Err.Description
    CreateDBPassword = False
End Function

2) Private Function ChangeDBPassword(ByVal OldPassword As String, _
        ByVal NewPassword As String, ByVal Path As String) As Boolean
    Dim objConn as ADODB.Connection
    Dim strAlterPassword as String

    On Error GoTo ChangeDBPassword_Err

    ' Create the SQL string to change the database password.
    strAlterPassword = "ALTER DATABASE PASSWORD [NewPassword]
[OldPassword];"

    ' Open the secured database.
    Set objConn = New ADODB.Connection
    With objConn
        .Mode = adModeShareExclusive
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Properties("Jet OLEDB:Database Password") = "OldPassword"
        .Open "Data Source=Path;"

        ' Execute the SQL statement to change the password.
        .Execute (strAlterPassword)
    End With

    ' Clean up objects.
    objConn.Close
    Set objConn = Nothing

    ChangeDBPassword = True

ChangeDBPassword_Err:
    Msgbox Err.Number & ":" & Err.Description
    ChangeDBPassword = False
End Function

Regards,
Zuzar.L.

"Jassim Rahma" <jra...@hotmail.com> wrote in message

news:13f7101c29418$8feaa240$8df82ecf@TK2MSFTNGXA02...
> how can I check if and mdb password is password protected
> or not? I need to write a code to check if the the mdb
> file was not password, then setup a password for it.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google