Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
If TextBox3.Text <> TextBox5.Text Then
Label1.Text = "两次输入的密码不相同,请重新输入"
Else
OleDbSelectCommand1.CommandText = "SELECT UserID,Password FROM Center_User WHERE UserID = " & Session("UserID") & " and Password=" & Session("Password") & ""
DataSet11.Tables("Center_User").Clear()
OleDbDataAdapter1.Fill(DataSet11, "Center_User")
Try
DataSet11.Tables("Center_User").Rows(0).Item("UserID") = TextBox4.Text
DataSet11.Tables("Center_User").Rows(0).Item("Password") = TextBox3.Text
OleDbDataAdapter1.Update(DataSet11, "Center_User")
Catch
Label1.Text = "用户名重复,请重新输入"
Exit Sub
Finally
End Try
Label1.Text = "您已经成功修改"
End If
End Sub
问题是一直显示用户名重复,请重新输入,提交不到数据库
1. can you catch the error to see what is wrong?
....
Catch ex as Exception
Label1.Text = ex.Message
2. try to change Password to [Password]
3. or just try
OleDbSelectCommand1.CommandText = "Update Center_User Set UserID=" & TextBox4.Text & ",[Password] = " & TextBox3.Text & " WHERE UserID = " & Session("UserID") & " and [Password]=" & Session("Password") & ""
Conn.Open()
dim n as Integer = OleDbSelectCommand1.ExecuteNonQuery()
if n = 0 then
Label1.Text = "something is wrong"
else
Session("UserID") = TextBox4.Text
Session("Password") = TextBox3.Text
Label1.Text = "您已经成功修改"
end if