Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default query for "all"

    I have a form that queries a database by "day".

    The form values are the days of the week, but I want to add a value for "no
    preference" where the results would be all values. I tried to string
    together all of the days (i.e.: "Monday" AND "Tuesday" AND...) in the form
    value, but the query can't evaluate it. It just returns results for the
    first value.

    Any idea how to do this...must be simple, right?

    Thanks,
    Rich



    Rich Palarea Guest

  2. Similar Questions and Discussions

    1. Proj cannot run on LCDS 2.6 ES due to "Unable to resolveresource bundle "datamanagement" for locale "en_US"
      hi, all, We have developped an application on Flex Build 3 (run successfully), but failed when we try to deploy it on Tomcat with LCDS 2.5 ES...
    2. ColdFusion+cfquery+Oracle+CLOB+"Query of Query"
      Error message is: Query Of Queries runtime error. Unsupported SQL type "java.sql.Types.CLOB". My database table: RESMIGAZETEFIHRISTI: ...
    3. cfgrid inside a <cfoutput query="myQuery" group="GROUP">
      Is it possible to use a cfgrid inside a cfoutput with a query and a group. When I try do that I get the following error: INVALID_CHARACTER_ERR:...
    4. CFINPUT type="radio" w/ "value" requires "label"
      On a Flash form, when you specify type='radio' and value='whatever', the value of the 'value' attribute will be displayed as a label if no 'label'...
    5. "Start" "Program" "Menu" list is empty
      For what ever reason my list of installed programs in my "Start" "Programs" menu is empty. Anyone know how to restore the list. Thanks for your...
  3. #2

    Default Re: query for "all"

    Rich Palarea wrote:
    > I have a form that queries a database by "day".
    >
    > The form values are the days of the week, but I want to add a value
    > for "no preference" where the results would be all values. I tried
    > to string together all of the days (i.e.: "Monday" AND "Tuesday"
    > AND...) in the form value, but the query can't evaluate it. It just
    > returns results for the first value.
    >
    > Any idea how to do this...must be simple, right?
    >
    > Thanks,
    > Rich
    Option 1:
    Change AND to OR:
    Field = "Monday" OR Field = "Tuesday" ...

    Option 2 (Better):
    Use IN
    .... Field IN ("Monday","Tuesday",...)

    Option 2 (Best):
    Don't add this field to the WHERE clause if the value is "no performance"

    HTH,
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  4. #3

    Default Re: query for "all"

    On Thu, 30 Oct 2003 16:18:31 -0500, "Rich Palarea" <nospam@none.com>
    wrote:
    >I have a form that queries a database by "day".
    >
    >The form values are the days of the week, but I want to add a value for "no
    >preference" where the results would be all values. I tried to string
    >together all of the days (i.e.: "Monday" AND "Tuesday" AND...) in the form
    >value, but the query can't evaluate it. It just returns results for the
    >first value.
    >
    >Any idea how to do this...must be simple, right?
    Just leave the WHERE clause for day of week off the query when "No
    Preference" is selected on the form.

    Jeff
    Jeff Cochran Guest

  5. #4

    Default Re: query for "all"

    Jeff:

    Since I'm submitting values from a web form against a SELECT statement that
    is already written, how would I go about modifying the SQL on the fly?

    Thanks,
    Rich


    "Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    news:3fa2633a.220473974@msnews.microsoft.com...
    > On Thu, 30 Oct 2003 16:18:31 -0500, "Rich Palarea" <nospam@none.com>
    > wrote:
    >
    > >I have a form that queries a database by "day".
    > >
    > >The form values are the days of the week, but I want to add a value for
    "no
    > >preference" where the results would be all values. I tried to string
    > >together all of the days (i.e.: "Monday" AND "Tuesday" AND...) in the
    form
    > >value, but the query can't evaluate it. It just returns results for the
    > >first value.
    > >
    > >Any idea how to do this...must be simple, right?
    >
    > Just leave the WHERE clause for day of week off the query when "No
    > Preference" is selected on the form.
    >
    > Jeff

    Rich Palarea Guest

  6. #5

    Default Re: query for "all"

    Rich Palarea wrote:
    > Jeff:
    >
    > Since I'm submitting values from a web form against a SELECT
    > statement that is already written, how would I go about modifying the
    > SQL on the fly?
    >
    Wow! That really threw me. You'd better show us this code. It sounded as if
    you were creating this SQL statement on the fly. I cannot understand what
    you mean by "already written". Are you talking about a stored procedure?

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  7. #6

    Default Re: query for "all"

    Here is how the form is setup:

    <select size="1" name="MeetingDay">
    <option>Monday</option>
    <option>Tuesday</option>
    <option>Wednesday</option>
    <option>Thursday</option>
    <option>Friday</option>
    <option>Saturday</option>
    <option>Sunday</option>
    <option value=WHAT DO WE PUT HERE?>No Preference</option>
    </select>

    Here is the SQL that takes the form input to return results:

    "SELECT * FROM View_Smallgroups WHERE (MeetingDay = '::MeetingDay::') ORDER
    BY MeetingDay ASC,NGLocation ASC"

    Thanks,
    Rich

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OGuud5%23nDHA.2808@TK2MSFTNGP10.phx.gbl...
    > Rich Palarea wrote:
    > > Jeff:
    > >
    > > Since I'm submitting values from a web form against a SELECT
    > > statement that is already written, how would I go about modifying the
    > > SQL on the fly?
    > >
    > Wow! That really threw me. You'd better show us this code. It sounded as
    if
    > you were creating this SQL statement on the fly. I cannot understand what
    > you mean by "already written". Are you talking about a stored procedure?
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Rich Palarea Guest

  8. #7

    Default Re: query for "all"

    Rich Palarea wrote:
    > Here is how the form is setup:
    >
    > <select size="1" name="MeetingDay">
    > <option>Monday</option>
    > <option>Tuesday</option>
    > <option>Wednesday</option>
    > <option>Thursday</option>
    > <option>Friday</option>
    > <option>Saturday</option>
    > <option>Sunday</option>
    Huh? none of these options have values. How are you passing them to the next
    page?
    > <option value=WHAT DO WE PUT HERE?>No
    > Preference</option> </select>
    >
    > Here is the SQL that takes the form input to return results:
    >
    > "SELECT * FROM View_Smallgroups WHERE (MeetingDay =
    > '::MeetingDay::') ORDER BY MeetingDay ASC,NGLocation ASC"
    >
    > Thanks,
    > Rich
    So change it to:

    strSQL = "SELECT * FROM View_Smallgroups "
    If Request.Form("MeetingDay") <> "No Preference" then
    strSQL = strSQL & " WHERE MeetingDay = '" & _
    Request.Form("MeetingDay") & "'"
    end if
    strSQL = strSQL & " ORDER BY MeetingDay ASC,NGLocation ASC"
    'Let's make sure the statement is correct:
    Response.Write strSQL

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  9. #8

    Default Re: query for "all"

    Bob - sorry, the options do have values of Monday, Tuesday, etc. (and they
    are working). Bad post - my bad!

    I'll try your SQL solution and report back. Thanks!

    Rich
    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:eGL4NI$nDHA.1708@TK2MSFTNGP12.phx.gbl...
    > Rich Palarea wrote:
    > > Here is how the form is setup:
    > >
    > > <select size="1" name="MeetingDay">
    > > <option>Monday</option>
    > > <option>Tuesday</option>
    > > <option>Wednesday</option>
    > > <option>Thursday</option>
    > > <option>Friday</option>
    > > <option>Saturday</option>
    > > <option>Sunday</option>
    >
    > Huh? none of these options have values. How are you passing them to the
    next
    > page?
    >
    > > <option value=WHAT DO WE PUT HERE?>No
    > > Preference</option> </select>
    > >
    > > Here is the SQL that takes the form input to return results:
    > >
    > > "SELECT * FROM View_Smallgroups WHERE (MeetingDay =
    > > '::MeetingDay::') ORDER BY MeetingDay ASC,NGLocation ASC"
    > >
    > > Thanks,
    > > Rich
    >
    > So change it to:
    >
    > strSQL = "SELECT * FROM View_Smallgroups "
    > If Request.Form("MeetingDay") <> "No Preference" then
    > strSQL = strSQL & " WHERE MeetingDay = '" & _
    > Request.Form("MeetingDay") & "'"
    > end if
    > strSQL = strSQL & " ORDER BY MeetingDay ASC,NGLocation ASC"
    > 'Let's make sure the statement is correct:
    > Response.Write strSQL
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Rich Palarea Guest

  10. #9

    Default Re: query for "all"

    Hi Rich,

    Where did you compose the query string, client script or serve side ASP
    code? I think you may first check the value of combobox "MeetingDay" and
    then determine the query string just like what Bob suggested. Is there any
    concern with this way?

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

  11. #10

    Default Re: query for "all"

    Luke:

    It was done through the FrontPage DRW (2002). Bob's solution worked great!
    So, the values in the combo box, for example, are instantiated inside of the
    FrontPage code within the wizard.

    Thanks,

    Rich
    "MSFT" <lukezhan@online.microsoft.com> wrote in message
    news:J6$iWcqoDHA.2088@cpmsftngxa06.phx.gbl...
    > Hi Rich,
    >
    > Where did you compose the query string, client script or serve side ASP
    > code? I think you may first check the value of combobox "MeetingDay" and
    > then determine the query string just like what Bob suggested. Is there any
    > concern with this way?
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    Rich Palarea Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139