6
Answers

Query for a combobox and textbox to search within a datagrid

Baka Musky

Baka Musky

7y
178
1
Hey everyone,

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. 
Answers (6)