Hello,
I need help with "Advanced Search". I've seen other applications having a form that user can build queries from comboboxes choosing its own criteria and show them as reports.
For example in the first combobox they choose Table, then field,then criteria.
Is there any examples or explanation of how these works?
Thank you in advance.
Loading

Jisss shyam13 reputationPosted Oct 21, 2009, 1:59 AM EDT
you can create sql statements like this
string sql = "SELECT * FROM " + comoTable.Text + " WHERE " + comboField.Text + " " + comboCriteria.Text + " " + comboCritParam.Text + "";
you can change statement according to comboboxes and other controls
thanks
nitin murkute12 reputationPosted Oct 6, 2009, 2:21 AM EDT
DealyRank #9,518 · 205 reputationPosted Oct 12, 2009, 10:36 PM EDT
With the above user will create its own queries dynamically.
DealyRank #9,518 · 205 reputationPosted Oct 22, 2009, 11:54 PM EDT
theLizardRank #1,079 · 1.8K reputationPosted Oct 23, 2009, 12:15 AM EDT
You should also consider using check boxes for selecting > < = != because you could have more than one selection criteria in the WHERE clause ie name <= 'smith' OR name >= 'thomas' OR name != 'thompson' AND country = 'mycountry'
You may also want to use conditionals to create your sql statement ie, you would have a check box to include an ORDER BY part or GROUP BY.