VB 删除 ACCESS 数据库的密码

VB 删除 ACCESS 数据库的密码,第1张

概述删除函数: Public Sub RemoveDatabase_Password(ByVal strDBWithPassword As String, ByVal strPassword As String)                         On Error GoTo ErrorHandler Dim objEngine As New JRO.JetEngine Dim strBa

删除函数:

Public Sub RemoveDatabase_Password(ByVal strDBWithPassword As String,ByVal strPassword As String)

On Error GoTo ErrorHandler
Dim objEngine As New JRO.JetEngine
Dim strBackupfile As String
Dim strDBWithOutPassword As String
Dim DBWithPwd As String,DBWithOutPwd As String

If Len(Dir(strDBWithPassword)) And Len(strPassword) <> 0 Then
' 是否备份
If MsgBox("删除密码之前是否备份源数据库?",vbYesNo,"提示") = vbYes Then
strBackupfile = "C:\Mybackup.mdb"
If Len(Dir(strBackupfile)) Then Kill strBackupfile
filecopy strDBWithPassword,strBackupfile
End If

'建立临时文件
strDBWithOutPassword = "c:\Temp40005.mdb"
If Len(Dir(strDBWithOutPassword)) Then Kill strDBWithOutPassword '若临时文件存在,删除临时文件

DBWithPwd = "ProvIDer=Microsoft.Jet.olEDB.4.0;Data Source=" _
& strDBWithPassword & ";" & "Jet olEDB:Database Password=" & strPassword & ";"

DBWithOutPwd = "ProvIDer=Microsoft.Jet.olEDB.4.0;Data Source=" _
& strDBWithOutPassword & " ;Jet olEDB:Engine Type=5;"

DoEvents

objEngine.CompactDatabase DBWithPwd,DBWithOutPwd
Set objEngine = nothing

'删除有密码的数据库
Kill strDBWithPassword
'复制去除密码大数据
filecopy strDBWithOutPassword,strDBWithPassword
Kill strDBWithOutPassword '删除临时数据库

MsgBox "恭喜,密码已成功从数据中删除",vbinformation,"成功"
Else

MsgBox "输入的数据库密码不正确!",vbCritical,"失败"

End If

Exit Sub
ErrorHandler:
If Err.Number = -2147217843 Then
MsgBox "密码无效请重试!","密码错误"
Else
MsgBox "错误 # " & Err.Number & " : " & Err.Description & _
" in RemoveDatabase_Password()",vbOKOnly,"提示"
End If
End Sub

调用方法:

Call RemoveDatabase_Password(‘数据库路径','数据库密码')

敬告:

莫做恶事!鄙视恶意攻击者!

总结

以上是内存溢出为你收集整理的VB 删除 ACCESS 数据库的密码全部内容,希望文章能够帮你解决VB 删除 ACCESS 数据库的密码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1285338.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存