I have a form with 3 combo boxes. The value of the combo boxes generates a SQL query with 3 parameters. The SQL generates a RDLC report.
For example:
Combox1 with values(v1,v2,v3,ALL)
Combox2 with values(v1,v2,ALL)
Combox3 with values(v1,v2,v3,4,ALL)
Me.ExampleTableAdapter.QueryWithParams(Me.ExampleDataSet.Table, Combobox1.SelectedIndex, Combobox2.SelectedIndex,Combobox1.SelectedIndex)
QueryWithParams:
SELECT * FROM Table WHERE Column1=@c1 AND Column2=@c2 AND Column3=@c3
Ok, the problem is when the selected value is ALL in the combo X, I cannot get the values because I must change the query and kick out the parameter. For example: If the combo1, combo2, combo3 have the values ALL. I don't need parameters.
SELECT * FROM Table
If the combo1 is ALL.
SELECT * FROM Table WHERE Column2=@c2 AND Column3=@c3
If combo1 and combo3 are ALL
SELECT* FROM Table WHERE Column2=@c2
... Then in code I look which is the selected value of the combo and upon it I do the query.
Is there a way that i do this thing without generating all 8 types of queries?
PS. I cannot use stored procedures because I'm using SQL Server Compact