This is a simple function that returns TRUE if the user exists in the users table, false otherwise.
For some reason it is always return false, I even removed the WHERE clause and I still get false? (a manual check in query analyzer tells me I have lots of rows?)
Public Shared Function DoesUserExist(ByVal userID As Integer) As Boolean
Dim retValue As Boolean
retValue = False
Using conn As New SqlConnection(GetConnectionString())
'Dim cmd As SqlCommand = New SqlCommand("SELECT user_ID FROM users WHERE user_ID = @userID", conn)
Dim cmd As SqlCommand = New SqlCommand("SELECT user_ID FROM users", conn)
cmd.Parameters.Add("@userID", SqlDbType.NVarChar).Value = userID
cmd.CommandType = CommandType.Text
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
'If Not reader Is Nothing Then
' HttpContext.Current.Response.Write("<br>Null")
'End If
If reader.Read() Then
retValue = True
End If
conn.Close()
cmd.Dispose()
End Using
retValue = False
Return retValue
End Function