I'm using a DataGridView to display data from an MSSQL database. I have several text input fields that when an onkeyup event is registered, it performs a lookup query (using a table adapter) with the text field as a parameter to the SQL string.
My database is currently setup to have some nullable fields.
When I have a zero-length string value in the text input field, the value is NOT null, therefore the SQL Select does not match (LIKE clause) the text box value to the NULL value in the database.
What is the best way to handle this situation? Convert all the empty fields in the database to NULL?
I could convert any blank input strings to null when querying the database, but this would then mean that any fields in the database that are empty strings and not actually null would be excluded.
I think I might be missing something obvious, I cannot find any similar problems online, but if anyone can point me in the right direction that would be great!