Im trying to create a sql question in asp.net that i use for searching from textbox values, the sql i've made works if i search in both textboxes but i want to be able to just search in one and get a result, if i search in one i get the following error: "An exception of type 'System.NullReferenceException' occurred in Projektet.dll but was not handled in user code"
this is the sql
NpgsqlCommand command = new NpgsqlCommand("SELECT * FROM person WHERE (fornamn LIKE '" + namn.ToUpper() + "%' OR fornamn LIKE '" + namn.ToLower() + "%' AND efternamn LIKE '" + enamn.ToUpper() + "%' OR efternamn LIKE '" + enamn.ToLower() + "%') AND roll = 1 ORDER BY person_id", conn);