Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Dynamic SQL Query in ASP

Posted 07 Jan 2005 13:24:48
1
has voted
07 Jan 2005 13:24:48 Chriz L. posted:
Is it possible to use dynamic "WHERE ..." in a " SELECT ..." query?

Bacause i don't know the number of "WHERE" parameters i want if one parameter is checked to be added in the "WHERE"

Here is an example of what i mean.
I have a form with checkboxes, each one represent something eg. Name, Country, Occupation. When i submit the form i want to create the SQL Statement and if, for example, the name and occupation are checked to execute an sql statement of this form: "SELECT ..... WHERE Name= name AND Occupation= occupation".

Any suggestions?

Thank you in advance.

Edited by - dealwi8me on 07 Jan 2005 13:25:34

Replies

Replied 07 Jan 2005 22:33:03
07 Jan 2005 22:33:03 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Is it possible to use dynamic "WHERE ..." in a " SELECT ..." query?<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Yes, in fact when you choose a "filter" in the simple Recordset dialog, the "filter" is WHERE clause. Setup the basic query, then go into Advanced query mode, then change it to a dynamic parameter.
Replied 08 Jan 2005 10:42:59
08 Jan 2005 10:42:59 Chriz L. replied:
What you mean is to construct a variable with all checked variables and then add this at WHERE clause right?

I will try it.
Thank you!

Reply to this topic