关于密码修改的问题
txtnewpwd和txtnewpwd2是密码和密码确认文本框,下边是我的程序:
If txtnewpwd.Text = txtnewpwd2.Text Then
Dim comstr As String
comstr = "update 登录 set pwd= ' " & CChar(txtnewpwd.Text) & " '_where name= ' " & txtuser.Text & " ' "
Dim sqlcom As New OleDb.OleDbCommand(comstr, OleDbConnection1)
OleDbConnection1.Open()
sqlcom.ExecuteNonQuery()
MsgBox( "修改成功,请记住新密码! ")
Me.Close()
Else
MsgBox( "两次密码不同! ")
txtnewpwd.Text = " "
txtnewpwd2.Text = " "
txtnewpwd.Focus()
End If
程序一运行就到sqlcom.ExecuteNonQuery()卡住了,这是为什么??
[解决办法]
Dim Conn As OleDbConnection
Dim Cmd As OleDbCommand
Dim SQL As String
Dim Provider = "Provider=Microsoft.Jet.OLEDB.4.0 "
Dim Database = "Data Source= " & Application.StartupPath() & "\login.mdb "
If txtnewpwd.Text = txtnewpwd2.Text Then
Conn = New OleDbConnection(Provider & "; " & Database)
Conn.Open()
SQL = "Update 登录 Set pwd=@pwd Where name= ' " & txtuser.Text & " ' "
Cmd = New OleDbCommand(SQL, Conn)
Cmd.Parameters.Add(New OleDbParameter( "@pwd ", OleDbType.Char, 50))
Cmd.Parameters( "@pwd ").Value = txtnewpwd.Text
Cmd.ExecuteNonQuery()
Conn.Close()
MsgBox( "修改成功,请记住新密码! ")
Me.Close()
Else
MsgBox( "两次密码不同! ")
txtnewpwd.Text = " "
txtnewpwd2.Text = " "
txtnewpwd.Focus()
End If