I have a select case to chose what is true. THe problem is if the information isn't in the database, it automatically skips to the else however i dont kno why.
I have a function that returns an errmessage once it is returned then i use the select case.
the code for the function is:
Function SQLCHECKUSER() As Object
Dim query1 As String = "SELECT [User_Name] FROM [FDXUSER] WHERE ([User_Name] ='" & User_Name.Text & "')"
Dim query2 As String = "SELECT [employee_number] FROM [FDXUSER] WHERE ([employee_number] ='" & empnumber.Text & "')"
Dim query3 As String = "SELECT [Email] FROM [FDXUSER] WHERE ([Email] ='" & email_address.Text & "')"
Dim sqlcommand As New OleDbCommand(query1, Sqlconnection)
Dim sqlcommand2 As New OleDbCommand(query2, Sqlconnection)
Dim sqlcommand3 As New OleDbCommand(query3, Sqlconnection)
Dim obj As Object
Dim obj2 As Object
Dim obj3 As Object
obj = sqlcommand.ExecuteScalar()
obj2 = sqlcommand2.ExecuteScalar()
obj3 = sqlcommand3.ExecuteScalar()
If obj & obj2 & obj3 Is Nothing Then
Return errmessage = "SUCCESS"
Else
If obj Is Nothing Then
Return errmessage = "INSERT"
Else
Return errmessage = "USER"
End If
If obj2 Is Nothing Then
Return errmessage = "INSERT"
Else
Return errmessage = "EMPLOYEE"
End If
If obj3 Is Nothing Then
Return errmessage = "INSERT"
Else
Return errmessage = "EMAIL"
End If
End If
End Function
Then the select case is:
SQLCHECKUSER()
Select Case errmessage
Case errmessage = "EMPLOYEE"
pageerrorlbl.Text = "Sorry! The Employeed Number You have entered already exist. Please Contact the Web Admin if you think this is a mistake."
Exit Sub
Case errmessage = "USER"
pageerrorlbl.Text = "Sorry! The User Name You have entered already exist. Please Contact the Web Admin if you think this is a mistake."
Exit Sub
Case errmessage = "EMAIL"
pageerrorlbl.Text = "Sorry! The Email Address You have entered already exist. Please Contact the Web Admin if you think this is a mistake."
Exit Sub
Case errmessage = "INSERT" Or errmessage = "SUCCESS"
Sqlcommand.CommandText = sqlinsert
Sqlcommand.Connection = Sqlconnection
Sqlcommand.ExecuteNonQuery()
Response.Redirect("confirmreg.aspx")
Exit Select
Case errmessage = "FAILED"
pageerrorlbl.Text = "Sorry! Something is wrong. Please contact the administrator"
Exit Select
Case Else
pageerrorlbl.Text() = "SKIPPED EVERYTHING"
Exit Select
End Select
for some reason it skips the entire select case command and goes straight for else.