Access数据库中如何修改用户密码?
我想问下在Access中如何修改用户密码的编程?用VBA编的并且要把用户表里面的数据也要更新!~谢谢...
我想问下在Access中如何修改用户密码的编程?用VBA编的
并且要把用户表里面的数据也要更新!~
谢谢 展开
并且要把用户表里面的数据也要更新!~
谢谢 展开
2013-12-29
展开全部
使用DAO方式改变密码
Private Sub cmdChangeDAO_Click()
Dim strNewPassword As String
'Check if a database is open
If fDC Then 'using data control
'Get new password
strNewPassword = InputBox("Please type in new password. Leave blank to remove password protection")
'Change password
Data1.Database.NewPassword strPassword, strNewPassword
Else
If strSource = "" Then
MsgBox "No current database open"
Else
'Get new password
strNewPassword = InputBox("Please type in new password. Leave blank to remove password protection")
'Change password
db.NewPassword strPassword, strNewPassword
End If
End If
'Update variable
strPassword = strNewPassword
WriteCaptions fDAO
End Sub
使用ADO方式改变密码
Private Sub cmdChangeADO_Click()
Dim strNewPassword As String
Dim strsql As String
If fDC Then 'using data control
'cannot change password from ADODC
MsgBox "You have opened the database with ADODC data control. This control is not capable of changing the database password." & vbCrLf & "Use ADO Code connection string to achieve this."
Else
'Check if a database is open
If strSource = "" Then
MsgBox "No current database open"
Else
'Get new password
strNewPassword = InputBox("Please type in new password. Leave blank to remove password protection")
'Change password
If strNewPassword = "" Then 'Remove password
strsql = "ALTER Database Password `` " & strPassword
Else
If strPassword = "" Then 'no current password
strsql = "ALTER Database Password " & strNewPassword & " ``"
Else 'straight forward change
strsql = "ALTER Database Password " & strNewPassword & " " & strPassword
End If
End If
cnn.Execute strsql
End If
End If
'Update variable
strPassword = strNewPassword
WriteCaptions fDAO
End Sub
Private Sub cmdChangeDAO_Click()
Dim strNewPassword As String
'Check if a database is open
If fDC Then 'using data control
'Get new password
strNewPassword = InputBox("Please type in new password. Leave blank to remove password protection")
'Change password
Data1.Database.NewPassword strPassword, strNewPassword
Else
If strSource = "" Then
MsgBox "No current database open"
Else
'Get new password
strNewPassword = InputBox("Please type in new password. Leave blank to remove password protection")
'Change password
db.NewPassword strPassword, strNewPassword
End If
End If
'Update variable
strPassword = strNewPassword
WriteCaptions fDAO
End Sub
使用ADO方式改变密码
Private Sub cmdChangeADO_Click()
Dim strNewPassword As String
Dim strsql As String
If fDC Then 'using data control
'cannot change password from ADODC
MsgBox "You have opened the database with ADODC data control. This control is not capable of changing the database password." & vbCrLf & "Use ADO Code connection string to achieve this."
Else
'Check if a database is open
If strSource = "" Then
MsgBox "No current database open"
Else
'Get new password
strNewPassword = InputBox("Please type in new password. Leave blank to remove password protection")
'Change password
If strNewPassword = "" Then 'Remove password
strsql = "ALTER Database Password `` " & strPassword
Else
If strPassword = "" Then 'no current password
strsql = "ALTER Database Password " & strNewPassword & " ``"
Else 'straight forward change
strsql = "ALTER Database Password " & strNewPassword & " " & strPassword
End If
End If
cnn.Execute strsql
End If
End If
'Update variable
strPassword = strNewPassword
WriteCaptions fDAO
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询