I am trying to make a MySQL database search in my C# WindowsForms app. I have 16 search values (for example: age, status, height, weight, ... etc.). The thing is, that I do not need to fill all values to perform the search and I do not know how to set up the query string. If I will fill fields only for "age" and "status" It should look something like:
string querySearch = " SELECT * FROM table WHERE age=" + value1 +"status="+value2;
MySqlCommand cmdSearch = new MySqlCommand(querySearch, conn);
readerSearch = cmdSearch.ExecuteReader();
readerSearch.Read();
but I dont know how many fields would the user like to fill, so I have to write the query (WHERE part) more dynamically. Can anyone please suggest how to approach this? Thank you.