Results 1 to 2 of 2

Thread: If statements within ASPDB Pro

  1. #1
    Stuart Paice Guest

    If statements within ASPDB Pro

    hi, within my code i have can have request from another page which may assign an ID to apply a search on the SQL query. i can also access this page from another tab which should select all ID's in that database.

    what i am trying to achive is to apply a if statement where ASPDB gets the SQL query and apply code like

    request("request_ID&#34 = LOCALID

    if request("request_ID&#34 = NULL then
    SQL = "SELECT * FROM database_table
    ELSE
    SQL = "SELECT * FROM database_table WHERE ID = LOCALID"
    END IF

    MyDb.dbSQL = sq

    is this correct if not the IF Statement is not selecting correctly can anyone help

    thank you
    Stuart

  2. #2
    John Guest

    If statements within ASPDB Pro (reply)


    Hi Stuart,

    You're on the right track. It should be more like this:

    If Requst(&#34;request_id&#34 <> &#34;&#34; Then
    Session(&#34;request_id_sql&#34 = &#34; WHERE ID = &#34; & Request(&#34;request_ID&#34
    End If

    SQL = &#34;SELECT * FROM database_table&#34; & Session(&#34;request_id_sql&#34

    x.dbSQL = SQL


    What this does is grab the request_id off the URL if it&#39;s there. It stores it in a session variable. If not there, then it uses the one from when it was passed previously. This is necessary because if the user hits the &#34;next&#34; button for example, the URL will change and the ID will be gone. If you don&#39;t save it, when hitting next, you get a different SQL and are all messed up.

    It then either appends a null string (the default session(request_id_sql)) or the previously passed ID file with the where condition to the usual SQL statement.

    Hope this helps,
    John



    ------------
    Stuart Paice at 2/4/2002 7:53:07 PM

    hi, within my code i have can have request from another page which may assign an ID to apply a search on the SQL query. i can also access this page from another tab which should select all ID&#39;s in that database.

    what i am trying to achive is to apply a if statement where ASPDB gets the SQL query and apply code like

    request(&#34;request_ID&#34 = LOCALID

    if request(&#34;request_ID&#34 = NULL then
    SQL = &#34;SELECT * FROM database_table
    ELSE
    SQL = &#34;SELECT * FROM database_table WHERE ID = LOCALID&#34;
    END IF

    MyDb.dbSQL = sq

    is this correct if not the IF Statement is not selecting correctly can anyone help

    thank you
    Stuart

Posting Permissions

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