0

I am trying to do my first web application using Visual Studio 2010 and Visual Basic as programming language. In my website, I have to do a Registration Form. When I tried to register a user in the application it always shown me an message error:

NullReference Exception was unhandled by the user code. Object reference not set to an instance of an object..

The problem is with the line of code: IF dr.HasRows Then Can someone help me please. Thanks a lot

Dim dr As SqlDataReader = 
 userDS.RegisterUser(txtUname.Text, strPwd, txtFname.Text, txtLname.Text,
    txtStreet.Text, txtTown.Text, txtCity.Text, txtTel.Text, txtEmail.Text)

If dr.HasRows Then
        Do While dr.Read()
            Session("userid") = dr.Item("User_ID").ToString()
            Session("username") = dr.Item("User_Name").ToString()
            Session("access") = dr.Item("Access").ToString()
        Loop
        'MsgBox("Welcome to MauriAuctions,  " & Session("username") & "! Your registration was successfully", MsgBoxStyle.Information, "Information")
        MesgBox("Welcome to MauriAuctions,  " & Session("username") & "! Your registration was successfully")

        If Session("location") = "POSTITEM" Then
            Response.Redirect("postItem.aspx")
        ElseIf Session("location") = "PLACEBID" Then
            Response.Redirect("placeBid.aspx?item_id=" & Session("itemId"))
        Else
            'Redirect on home page
            Response.Redirect("home.aspx")
        End If
    Else
        'MsgBox("An error was encountered when trying to register", MsgBoxStyle.Critical, "Error")
        MesgBox("An error was encountered when trying to register")
    End If
BenG
  • 13,680
  • 4
  • 41
  • 57
Banner
  • 19
  • 3

0 Answers0