I currently nearly finished a simple application, but my query doesnt work. I have a combobox and a textbox. By selecting a column name from the combobox, I want to be able to search in the textbox within that column. Anyone that can fix this query? I've been trying alot but havent had any succes yet.
SqlCommand command = new SqlCommand("SELECT * FROM dbo.Kwartaal " +
"WHERE '" + searchField + "' LIKE '% " + txtSearch.Text + "%' ", con);
Edit: searchField is my string that gets filled by selecting the column. txtSearch is the textbox obviously.

Amit GuptaRank #190 · 12.8K reputationPosted Jul 14, 2017, 4:10 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Jul 14, 2017, 3:45 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Jul 14, 2017, 3:29 AM EDT
Baka Musky8 reputationPosted Jul 14, 2017, 3:38 AM EDT
Baka Musky8 reputationPosted Jul 14, 2017, 4:03 AM EDT
It works now, but only with columns that has letters in it, if there are numbers and I search for an ID it doesnt work. Any fix on that?
Baka Musky8 reputationPosted Jul 14, 2017, 5:03 AM EDT