Imports System.Data
Imports System.Data.OleDb
Public Class frmChangePassword
Public dbrs As New OleDb.OleDbCommand
Public Provider As New OleDb.OleDbDataAdapter
Public dbConn As New OleDb.OleDbConnection
Private Sub frmChangePassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnChangePassword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangePassword.Click
Using cn As New OleDbConnection("PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = login.mdb"), _
cmd As New OleDbCommand("UPDATE LogInAdmin SET Password= ? WHERE Username= ? ;", cn)
cmd.Parameters.AddWithValue("?", txtNewPassword.Text)
cmd.Parameters.AddWithValue("?", txtUsername.Text)
cn.Open()
cmd.ExecuteNonQuery()
MsgBox("Changed")
cn.Close()
End Using
End Sub
End Class
答案 0 :(得分:1)
PASSWORD这个词是MS-Access / JET的保留关键字,你需要在它周围使用方括号
cmd As New OleDbCommand("UPDATE LogInAdmin SET [Password]= ? WHERE Username= ? ;", cn)
但是,使用这些reserved keywords是一个坏主意,如果仍有可能,我建议您更改该字段名称并了解如何存储hash of the password而不是明文。