Query returns what I expected it to return now with is null instead of != null, but I am still stuck as to why I am getting the exception in my c# application which is my main problem, Thanks
I have a column called UserId in a table WT_Users when I run the query
'select UserId from WT_Users;'
It returns a list of usersIds 1,2,3,4 which is fine but when I run the query
'select UserId from WT_Users where UserId != null'
No values are returned even thought I know that there are values held within the column. I ran these queries because I was originally working on a c# application and when I ran a reader with the first query above i got an exception 'Object reference not set to an instance of an object' when i tried to pull the value from the reader, even thought I have a 'HasRows' check and 'while read' check that were satisfied
SqlCommand findContactID = new SqlCommand("select UserId from WT_Users", con);
con.Open();
SqlDataReader dr7 = findContactID.ExecuteReader();
if (dr7.HasRows)
{
while (dr7.Read())
{
userIDs.Add(Convert.ToString(dr7.GetInt32(0)));
}
}
In visual studio I can even see that the reader does contain the values I what under Results view.
I have spent too much time already trying to figure this out and its probably something obvious. Thanks