丧尸末日的生存日记:vb.net 如何修改access数据库文件的密码

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 18:45:34

执行此sql语句即可:
"ALTER DATABASE PASSWORD 以前的密码 改后的密码"

If Trim(ypsw.Text) = "" Then
MsgBox("原密码不能为空!", MsgBoxStyle.Critical)
ElseIf Trim(xpsw.Text) = "" Then
MsgBox("新密码不能为空!", MsgBoxStyle.Critical)
ElseIf Trim(qpsw.Text) <> Trim(xpsw.Text) Then
MsgBox("确认密码与新密码不一致!", MsgBoxStyle.Critical)
Else
Dim mycon As New OleDbConnection
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\data\Datas.mdb"
mycon.Open()
Dim mycmd As New OleDbCommand
mycmd.CommandText = "select * from 管理员 where 用户名='admin' and 密码='" & ypsw.Text & " '"
mycmd.Connection = mycon
Dim myada As New OleDbDataAdapter
myada.SelectCommand = mycmd
Dim myda As New DataSet
myada.Fill(myda, "yh")
If myda.Tables("yh").Rows.Count < 1 Then
MsgBox("您输入的原密码不正确,请重新输入!", MsgBoxStyle.Critical)
ypsw.Focus()
Else
mycmd.CommandText = "update 管理员 set 密码='" & Trim(ypsw.Text) & " '"
mycmd.ExecuteNonQuery()
MsgBox("密码修改成功!", MsgBoxStyle.Information)
End If
End If