Professional Web Applications Themes

Adding variables to SQL statements from URL parameters - Microsoft SQL / MS SQL Server

I'm trying to set up a page that reads parameters (3 of them) passed by a form: Example: http://www.aamprogram.org/resources/useful_links_search2.aspx?category=cat_art&audienc e=aud_students&level=lvl_elementary&Submit=Search The user makes their choice from three drop down menus (http://www.aamprogram.org/resources/useful_links2.aspx). But since I don't know what the choices will be until the form is submitted, I'm capturing the choices with Request.QueryString("category") in a parameter: Example: <Parameters> <Parameter name="paraCategory" value='<%# IIf((Request.QueryString("category") <> Nothing), Request.QueryString("category"), "") %>' type="VarChar" /> <Parameter name="paraAudience" value='<%# IIf((Request.QueryString("audience") <> Nothing), Request.QueryString("audience"), "") %>' type="VarChar" /> <Parameter name="paraLevel" value='<%# IIf((Request.QueryString("level") <> Nothing), Request.QueryString("level"), "") %>' type="VarChar" /> </Parameters> At this point, I'm stuck and needing some help. ...

  1. #1

    Default Adding variables to SQL statements from URL parameters

    I'm trying to set up a page that reads parameters (3 of them) passed
    by a form:

    Example:

    http://www.aamprogram.org/resources/useful_links_search2.aspx?category=cat_art&audienc e=aud_students&level=lvl_elementary&Submit=Search

    The user makes their choice from three drop down menus
    (http://www.aamprogram.org/resources/useful_links2.aspx). But since I
    don't know what the choices will be until the form is submitted, I'm
    capturing the choices with Request.QueryString("category") in a
    parameter:

    Example:

    <Parameters>

    <Parameter name="paraCategory" value='<%#
    IIf((Request.QueryString("category") <> Nothing),
    Request.QueryString("category"), "") %>' type="VarChar" />

    <Parameter name="paraAudience" value='<%#
    IIf((Request.QueryString("audience") <> Nothing),
    Request.QueryString("audience"), "") %>' type="VarChar" />

    <Parameter name="paraLevel" value='<%#
    IIf((Request.QueryString("level") <> Nothing),
    Request.QueryString("level"), "") %>' type="VarChar" />

    </Parameters>

    At this point, I'm stuck and needing some help. I'm sure the solution
    is simple, but I'm new to SQL and vb.net and the solution is currently
    outside my awareness.



    Example:



    <%# "SELECT * FROM dbo.dbo_useful_links WHERE paraCategory = 1 AND
    paraAudience = 1 AND paraLevel = 1" %>'



    Am I barking up the wrong tree? Do you know of any good tutorials
    online? I've spent hours looking and can't find anything that works
    for me.

    The SQL database has columns for category check boxes (data type =
    bit), since some of the links are in multiple categories.



    I'd appreciate any guidance you can provide.
    strange Guest

  2. #2

    Default Re: Adding variables to SQL statements from URL parameters

    Hello Michael !

    As long as you use an aspx page, the query will be posted (back) to the
    form.
    So if you want to send the Form, you can use the values after posted back.

    In c# you would use the Form_Load event to decide wheter the Form ISPostback
    or not,
    then Query the string from the Querystring, create your SQL Statement and
    send it to the server.

    The dropdown boxes you want to use has two special attributes the
    displaycolumn and the value column,
    the value column is posted to the form.

    Then populate the result in HTML.

    Jens Süßmeyer.


    Jens Guest

  3. #3

    Default Re: Adding variables to SQL statements from URL parameters

    Jens,

    Hello back! Thanks for the quick reply.

    I'm using vb.net, not c#, and I'm very new to all this. Your solution
    makes sense to me conceptually, but do you know of any tutorials/posts
    that spell out the "step by step"?

    Thanks for your time.

    -Michael
    One day this will all make perfectly good sense...

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Michael Guest

  4. #4

    Default Re: Adding variables to SQL statements from URL parameters

    Hello Michael !

    Sorry but my books are german. try to help you with this query from Amazon.

    http://www.amazon.de/exec/obidos/external-search?tag=sqlserver-21&keyword=AS
    P.NET+VB.NET&index=books-de-intl-us"

    my Books are from " Hanser Fachbuch". Don´t know if they have books in
    English.

    Greets, Jens Süßmeyer.



    Jens Guest

  5. #5

    Default Re: Adding variables to SQL statements from URL parameters

    Jens,

    I found this five minutes ago...the "light went on" over my head.

    One of the biggest differences between ASP and ASP.NET is that in
    ASP.NET, a Web Form must post back to itself rather than post to a
    different page.

    I could almost cry...I'm moving towards a solution.

    Michael


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Michael Guest

Similar Threads

  1. Adding parameters to URL with fragment
    By Glenn Holliday in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: July 19th, 01:21 AM
  2. adding parameters
    By acidrain9 in forum Dreamweaver AppDev
    Replies: 0
    Last Post: February 19th, 08:19 PM
  3. Using variables in RegEx statements?
    By Rodney in forum PERL Miscellaneous
    Replies: 11
    Last Post: September 24th, 02:13 PM
  4. Parameters to SQL statements
    By Stephen Poley in forum PHP Development
    Replies: 2
    Last Post: July 18th, 06:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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