Ok so i have a Function that connects to a database and runs the executeschaler() command. the executeschaler is attached to an object. When running the command it will search the database for ceartin information and return certain values, however it returns an error when i use the Try End Try (catch ex as exception).
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 Or obj2 Or 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 FunctionFunction 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 Or obj2 Or 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
The error i get is: "Conversion from string "ctyokley" to type 'Long' is not valid. "
ctyokley is representing the usernam. So i tried the textbox.text.tostring and that didnt work. Any suggestions?