G
Guest
Hi,
most of the times I face the following situation: I have a relatively large
table (or a result of a joined tables) from what I have to display in a grid
some records, what correspond to some criteria. So what I do is: I place some
textboxes, combos, etc. to the top of the form and below goes a grid. When
the user fills out the text boxes, and chooses the appropriate values from
the combos, he clicks on a Filter button, and I have to show the records.
My question is: how should I set up the SQL sentence? Should I place for
every criteria/text box/combo a parameter? How can I remove them, if the user
not fills some values out?
I really don't want to filter at the client side, since it can take ages to
transfer thousands of records, when the user want only 10, what matches for
him...
I give an example:
Original query: select * from A, this would give back everything...
select * from A where x1=@x1 and x2=@x2 and x3=@x3: this would be the ideal
quers, when the user fills out three field on the form.
select * from A where x1=@x1 is the ideal query, when the user fills out
only the x1 field.
Is there any direct help to create such SQL sentences, and do all the
filtering at the server side?
Thanks:
Peter
most of the times I face the following situation: I have a relatively large
table (or a result of a joined tables) from what I have to display in a grid
some records, what correspond to some criteria. So what I do is: I place some
textboxes, combos, etc. to the top of the form and below goes a grid. When
the user fills out the text boxes, and chooses the appropriate values from
the combos, he clicks on a Filter button, and I have to show the records.
My question is: how should I set up the SQL sentence? Should I place for
every criteria/text box/combo a parameter? How can I remove them, if the user
not fills some values out?
I really don't want to filter at the client side, since it can take ages to
transfer thousands of records, when the user want only 10, what matches for
him...
I give an example:
Original query: select * from A, this would give back everything...
select * from A where x1=@x1 and x2=@x2 and x3=@x3: this would be the ideal
quers, when the user fills out three field on the form.
select * from A where x1=@x1 is the ideal query, when the user fills out
only the x1 field.
Is there any direct help to create such SQL sentences, and do all the
filtering at the server side?
Thanks:
Peter