Results 1 to 8 of 8

Thread: ado connection with password

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    ado connection with password

    Code:
    Public Sub APRI_CON()
    
        Set CON = New ADODB.Connection
        ' APRI CONNESSIONE
        With CON
            .Provider = "Microsoft.Jet.OLEDB.4.0"
            .Open strDBPath
        End With
    
    End Sub
    my conn.

    but if the database have a password i recive a error, "database password incorrect"

    i can allert the user for that?

    naturally exist sub if have errors i

  2. #2
    Junior Member
    Join Date
    May 2020
    Posts
    18

    Re: ado connection with password

    Hi could you try this cnn string
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDBatabase Password=MyDbPassword;

    source https://www.connectionstrings.com/mi...et-ole-db-4-0/

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: ado connection with password

    Quote Originally Posted by federico07 View Post
    Hi could you try this cnn string
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDBatabase Password=MyDbPassword;

    source https://www.connectionstrings.com/mi...et-ole-db-4-0/
    Hi!
    I know this way, but i need to know if the database have a password protected, before Open it...

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: ado connection with password

    well...if it fails when you attempt to open it without a password, ...guess what? it needs a password.

    Why not just attempt to open and trap the error?

    See this thread on how to do just that: https://social.msdn.microsoft.com/Fo...orum=vbgeneral
    Sam I am (as well as Confused at times).

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: ado connection with password

    Quote Originally Posted by SamOscarBrown View Post
    well...if it fails when you attempt to open it without a password, ...guess what? it needs a password.

    Why not just attempt to open and trap the error?

    See this thread on how to do just that: https://social.msdn.microsoft.com/Fo...orum=vbgeneral
    I have see....
    But i'm on vb6 not vbnet...

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: ado connection with password

    First you need share access. Then the above only gets one foot into the database itself. Next comes the user ID if the default "Admin" isn't right, then password, if one has been set.

    So there are three possible levels of access control to consider.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: ado connection with password

    sorry about the .Net link.... :-(
    Sam I am (as well as Confused at times).

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: ado connection with password

    i need to know if the database have a password protected, before Open it...
    ask the user (fill in textbox or whatever), then change the login to suit
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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