|
Post by adentutton on Oct 24, 2018 15:21:10 GMT
Hey guys!
I am looking to query my database with potentially multiple WHERE clauses based on filters in a dropdown list, is this possible?
Thanks!
Aden
|
|
|
Post by echo17 on Oct 25, 2018 13:17:11 GMT
You can definitely do this. SQL statements are just strings, so you can build your string to accommodate any dynamic condition. Some example psuedocode:
var sql = "SELECT * FROM Mytable WHERE "; for (var i = 0; i < dropDownCollection.Count; i++) { if (i > 0) { sql += "AND "; }
sql += "(SomeCondition = '" + dropDownCollection[i].Value.ToString() + "') "; }
|
|