PHP كود :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' TextBox1 = new password
' TextBox2 = old password
MsgBox(ChangeMSAccessDatabasePassword("C:\db1.mdb", TextBox1.Text, TextBox2.Text))
End Sub
Function ChangeMSAccessDatabasePassword(ByVal dbPath As String, ByVal newPass As String, ByVal oldPass As String) As Boolean
Dim ret As Integer
Try
Using cnn As New OleDb.OleDbConnection("Provider=" & IIf(dbPath.Trim.ToLower.EndsWith(".mdb"), "Microsoft.Jet.OLEDB.4.0", "Microsoft.ACE.OLEDB.12.0") & ";Data Source='" & dbPath & "';Jet OLEDB:Database Password=" & oldPass & ";Mode=Share Deny Read|Share Deny Write;")
Using cmd As New OleDb.OleDbCommand("ALTER DATABASE PASSWORD " & IIf(newPass <> "", "[" & newPass & "]", "Null") & IIf(oldPass <> "", "[" & oldPass & "]", "Null"), cnn)
cnn.Open()
ret = cmd.ExecuteNonQuery
cnn.Close()
End Using
End Using
If ret = 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
MsgBox(ex.Message)
Return False
End Try
End Function
End Class
