PDA

Click to See Complete Forum and Search --> : Registration Form error...{RESOLVED}


wrack
Jun 1st, 2003, 03:39 AM
Can someone please try this url to register and see what error they are getting...???

http://wrack.mine.nu/UniProject/Forms/Registration.aspx

When I run the project by pressing F5 it works like a charm but when someone else try to run that page from Internet they get an error...


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
txtUserName.Text = ""
txtPassword.Text = ""
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddress.Text = ""
txtSuburb.Text = ""
txtCity.Text = ""
txtState.Text = ""
txtPostCode.Text = ""
txtCountry.Text = "Australia"
txtEMail.Text = ""
txtContact.Text = ""
End If
End Sub

Private Sub cmdReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReset.Click
txtUserName.Text = ""
txtPassword.Text = ""
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddress.Text = ""
txtSuburb.Text = ""
txtCity.Text = ""
txtState.Text = ""
txtPostCode.Text = ""
txtCountry.Text = "Australia"
txtEMail.Text = ""
txtContact.Text = ""
End Sub

Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
Dim cnnRegistration As SqlConnection
Dim cmdRegistration As SqlCommand
Dim dtrRegistration As SqlDataReader
Dim strSQL As String

cnnRegistration = New SqlConnection("server=WRACK\SQLDB;uid=sa;pwd=;database=NW;")

strSQL = "SELECT [UserName] FROM tblUsers Where UserName = '" & txtUserName.Text & "' ORDER BY [UserName]"
cmdRegistration = New SqlCommand(strSQL, cnnRegistration)
cnnRegistration.Open()
dtrRegistration = cmdRegistration.ExecuteReader

If dtrRegistration.Read() Then
If Trim(txtUserName.Text) = Trim(dtrRegistration("UserName")) Then
lblError.Text = "User Name is not available. Please choose another User Name."
End If
Else
dtrRegistration.Close()
cnnRegistration.Close()

strSQL = "INSERT INTO tblUsers " & _
"(" & _
"[UserName], [Password], [FirstName], [LastName] ," & _
"[Address], [Suburb], [City], [State], [PostCode] ," & _
"[Country], [EMail], [Contact]" & _
") VALUES (" & _
"'" & txtUserName.Text & "', '" & txtPassword.Text & "', " & _
"'" & txtFirstName.Text & "', '" & txtLastName.Text & "', " & _
"'" & txtAddress.Text & "', '" & txtSuburb.Text & "', " & _
"'" & txtCity.Text & "', '" & txtState.Text & "', " & _
"'" & txtPostCode.Text & "', '" & txtCountry.Text & "', " & _
"'" & txtEMail.Text & "', '" & txtContact.Text & "')"

cmdRegistration = New SqlCommand(strSQL, cnnRegistration)

cnnRegistration.Open()

If ValidateEntry(txtUserName.Text, txtPassword.Text, txtFirstName.Text, _
txtLastName.Text, txtAddress.Text, txtSuburb.Text, _
txtCity.Text, txtState.Text, txtPostCode.Text, _
txtCountry.Text, txtEMail.Text) = True Then

dtrRegistration = cmdRegistration.ExecuteReader
lblError.Text = "Registration successful...Please go to Login page to gain access."
End If
End If

dtrRegistration.Close()
cnnRegistration.Close()
End Sub

Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
ValidateEntry = False
Else
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
ValidateEntry = False
Else
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
ValidateEntry = False
Else
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
ValidateEntry = False
Else
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
ValidateEntry = False
Else
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
ValidateEntry = False
Else
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
ValidateEntry = False
Else
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
ValidateEntry = False
Else
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
ValidateEntry = False
Else
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
ValidateEntry = False
Else
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
ValidateEntry = False
Else
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
ValidateEntry = False
Else
ValidateEntry = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function


I am getting this error...

hellswraith
Jun 1st, 2003, 09:01 AM
I get an error, but I can't see it because you have your custom error setting in your web config to something other than 'Off' If you set it to Off, then we can see the errors and get them back to you.

EyeTalion
Jun 1st, 2003, 09:55 AM
same here. get run-time error, but no description...also, you may want to place this code in it's own procedure...


txtUserName.Text = ""
txtPassword.Text = ""
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddress.Text = ""
txtSuburb.Text = ""
txtCity.Text = ""
txtState.Text = ""
txtPostCode.Text = ""
txtCountry.Text = "Australia"
txtEMail.Text = ""
txtContact.Text = ""

wrack
Jun 1st, 2003, 04:27 PM
Originally posted by hellswraith
I get an error, but I can't see it because you have your custom error setting in your web config to something other than 'Off' If you set it to Off, then we can see the errors and get them back to you. I will do it staight away...Please try again and let me know...

Cheers...

wrack
Jun 1st, 2003, 04:29 PM
Originally posted by EyeTalion
same here. get run-time error, but no description...also, you may want to place this code in it's own procedure...


txtUserName.Text = ""
txtPassword.Text = ""
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddress.Text = ""
txtSuburb.Text = ""
txtCity.Text = ""
txtState.Text = ""
txtPostCode.Text = ""
txtCountry.Text = "Australia"
txtEMail.Text = ""
txtContact.Text = ""
What exactly do u mean...??? You mean a seperate SUB and call it...

Cheers...

DevGrp
Jun 1st, 2003, 04:46 PM
Yes thats what he means. Also, you should use the error provider instead of using all those if else tests.

wrack
Jun 1st, 2003, 06:50 PM
Originally posted by DevGrp
Yes thats what he means. Also, you should use the error provider instead of using all those if else tests. OK I will use SUB and change it when I go home...

I try to used those RequiredValidator but the moment I hit the SUBMIT button all the fields were cleared and an EMPTY record was inserted into database...Note that the values weren't NULL so it went allright...

So I was pissed off and removed all of them and then used that long IF ELSE END IF thingy...

Cheers...

hellswraith
Jun 1st, 2003, 09:19 PM
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
ValidateEntry = False
Else
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
ValidateEntry = False
Else
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
ValidateEntry = False
Else
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
ValidateEntry = False
Else
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
ValidateEntry = False
Else
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
ValidateEntry = False
Else
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
ValidateEntry = False
Else
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
ValidateEntry = False
Else
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
ValidateEntry = False
Else
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
ValidateEntry = False
Else
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
ValidateEntry = False
Else
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
ValidateEntry = False
Else
ValidateEntry = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function

or:
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
Return False
End If

If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
Return False
End If

If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
Return False
End If

If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
Return False
End If

If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
Return False
End If

If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
Return False
End If

If s7 = "" Then
lblError.Text = "*City is REQUIRED."
Return False
End If

If s8 = "" Then
lblError.Text = "*State is REQUIRED."
Return False
End If

If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
Return False
End If

If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
Return False
End If

If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
Return False
End If

If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
Return False
End If

Return True
End Function


If you are going to do it that way, at least make it easier to look through.

wrack
Jun 1st, 2003, 10:22 PM
Originally posted by hellswraith

Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
ValidateEntry = False
Else
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
ValidateEntry = False
Else
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
ValidateEntry = False
Else
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
ValidateEntry = False
Else
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
ValidateEntry = False
Else
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
ValidateEntry = False
Else
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
ValidateEntry = False
Else
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
ValidateEntry = False
Else
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
ValidateEntry = False
Else
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
ValidateEntry = False
Else
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
ValidateEntry = False
Else
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
ValidateEntry = False
Else
ValidateEntry = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function

or:
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
Return False
End If

If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
Return False
End If

If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
Return False
End If

If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
Return False
End If

If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
Return False
End If

If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
Return False
End If

If s7 = "" Then
lblError.Text = "*City is REQUIRED."
Return False
End If

If s8 = "" Then
lblError.Text = "*State is REQUIRED."
Return False
End If

If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
Return False
End If

If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
Return False
End If

If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
Return False
End If

If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
Return False
End If

Return True
End Function


If you are going to do it that way, at least make it easier to look through. By your method is two fields are empty then it will overwrite the previous message in the lable...

But as far as I understand there is no problem doing the method I am using right now...

Problem is somewhere else...

Cheers...

wrack
Jun 1st, 2003, 10:49 PM
Just as I suspected...I just added a new form and copied all the controls and code to new and damn....Its working now like a charm...

Thanks for all ur support...

Cheers...