Hi, I get this error:
Server Error in '/e-library' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 58: Response.Write("Please type the same new password")
Line 59: End If
Line 60:
Line 61: If Page.IsValid Then
Line 62: Dim con As SqlConnection
Source File: c:\inetpub\wwwroot\e-library\UserPassword.aspx.
vb Line: 60
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
e_library.UserPassword.btnSubmit_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\e-library\UserPassword.aspx.
vb:60
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain() +1292
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim NewPwd As String
Dim RetypePwd As String
NewPwd = NewPwd.Trim
RetypePwd = RetypePwd.Trim
If NewPwd.Length < 4 Or NewPwd.Length > 10 Then
Response.Write("Password must be 4-10 characters!")
End If
If RetypePwd <> NewPwd Then
Response.Write("Please type the same new password")
End If
If Page.IsValid Then
Dim con As SqlConnection
Dim sql As String
Dim cmd As SqlCommand
Dim sb As New StringBuilder
Dim values As New ArrayList
sb.Append("UPDATE [User] SET ")
sb.Append("User_id='{0}', User_Password='{1}'")
values.Add(txtUserID.Text)
values.Add(txtNewPwd.Text)
values.Add(Context.User.Identity.Name)
sql = String.Format(sb.ToString(), values.ToArray())
con = New SqlConnection( _
"data source=(local)\NetSdk;initial catalog=E-Library Records;user id=sa")
cmd = New SqlCommand(sql, con)
con.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
lblMessage.Visible = True
lblMessage.Text = "Couldn't change your password."
Finally
con.Close()
End Try
lblPasswordMessage.Visible = True
lblPasswordMessage.Text = "You have changed your password successfully."
End If
End Sub
Hope somebody can help me.
Thanks!
Irene