Hi @Mansour_Dalir ,
You can refer to the following code,
Dim sttPassword As String
Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DbPath;"
Using connection As New OleDbConnection(connectionString)
Try
connection.Open()
Catch ex As OleDbException
If ex.ErrorCode = "The error code you get after testing" Then
sttPassword = TextBoxPwd.Text
connectionString += "Jet OLEDB:Database Password=" + sttPassword + ";"
connection.ConnectionString = connectionString
connection.Open()
Else
MessageBox.Show(ex.Message)
End If
Finally
connection.Close()
End Try
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.