Last post Sep 20, 2018 05:33 PM by PatriceSc
Sep 20, 2018 04:16 PM|JagjitSingh|LINK
I have below code and value in m_location is Null but it is still going in the below condition
strQuery = strQuery + " " + m_Location;
In Database when i run below command it shows no record but in field it shows Null
select * FROM [test].[dbo].[Data] where Location is null
Sep 20, 2018 05:17 PM|PatriceSc|LINK
This is what happens if m_Location or your db column is not null. Are you 100% sure you don't have a 4 character "null" string or may be whitespaces rather than really a string which is null ???
Try to show m_Location.Length. If it shows a value rather than throwing a NullReferenceException you do have a non null string.
Sep 20, 2018 05:25 PM|JagjitSingh|LINK
It shows NULL in field . When i run select statement for is null records it shows nothing. When i write select statement as field= 'NULL' then it shows records
Sep 20, 2018 05:33 PM|PatriceSc|LINK
And your db is ? Once again the behavior you describe is exactly what you have if storing a 4 characters 'NULL' string rather than really a NULL value.
Try SELECT LEN(field) FROM YourTable WHERE Field='NULL' -- Or maybe LENGTH depending on your db
If it shows 4 rather than NULL you definitively stored a 'NULL' string in your db.