check if database have a passowrd

User avatar
sal21
PlatinumLounger
Posts: 4354
Joined: 26 Apr 2010, 17:36

check if database have a passowrd

Post by sal21 »

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

i can alert the user if the database have a paswword, before open it?

in my case have error in image
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78453
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: check if database have a passowrd

Post by HansV »

You might use an error handler:

Code: Select all

Public Sub APRI_CON()
    Set CON = New ADODB.Connection
    On Error GoTo ErrHandler
    ' APRI CONNESSIONE
    With CON
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Open strDBPath
    End With
    Exit Sub
ErrHandler:
    MsgBox "Cannot open the connection!", vbCritical
    Set CON = Nothing
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4354
Joined: 26 Apr 2010, 17:36

Re: check if database have a passowrd

Post by sal21 »

HansV wrote:
22 Jan 2021, 20:13
You might use an error handler:

Code: Select all

Public Sub APRI_CON()
    Set CON = New ADODB.Connection
    On Error GoTo ErrHandler
    ' APRI CONNESSIONE
    With CON
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Open strDBPath <<<<<
    End With
    Exit Sub
ErrHandler:
    MsgBox "Cannot open the connection!", vbCritical
    Set CON = Nothing
End Sub
IN <<<< exactlly the same error in image, and code stop the execution, dont go in ErrHandler:....

User avatar
HansV
Administrator
Posts: 78453
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: check if database have a passowrd

Post by HansV »

Perhaps you could use DAO instead of ADO...
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4354
Joined: 26 Apr 2010, 17:36

Re: check if database have a passowrd

Post by sal21 »

HansV wrote:
23 Jan 2021, 11:34
Perhaps you could use DAO instead of ADO...
Ok i test It.