What's wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oli

    What's wrong?

    Hi

    URL in address bar:


    SQLQuery = "SELECT * from Applicant WHERE pID="' & Request.Queryst ing('pID')
    & '"

    But it only gets: SELECT * from Applicant WHERE pID=

    This is only simple but is causing me a headache!

    Any ideas??
    TIA - Oli


  • stewert gallington

    #2
    Re: What's wrong?

    You've miss spelt querystring as querysting.

    To avoid this problem you can just refer to it like:

    request('pID')

    Its also handy because you can use it to locate a variable anywhere, be it
    in the querystring or on a form thats submitted.

    "Oli" <oli@NOSPAMoliw oods.co.uk> wrote in message
    news:bqpp0l$1p4 $1@sparta.btint ernet.com...[color=blue]
    > Hi
    >
    > URL in address bar:
    > http://localhost/edituser.asp?pID=1
    >
    > SQLQuery = "SELECT * from Applicant WHERE pID="' &[/color]
    Request.Queryst ing('pID')[color=blue]
    > & '"
    >
    > But it only gets: SELECT * from Applicant WHERE pID=
    >
    > This is only simple but is causing me a headache!
    >
    > Any ideas??
    > TIA - Oli
    >
    >[/color]


    Comment

    • Bob Barrows

      #3
      Re: What's wrong?

      Oli wrote:[color=blue]
      > Hi
      >
      > URL in address bar:
      > http://localhost/edituser.asp?pID=1
      >
      > SQLQuery = "SELECT * from Applicant WHERE pID="' &
      > Request.Queryst ing('pID') & '"
      >
      > But it only gets: SELECT * from Applicant WHERE pID=
      >
      > This is only simple but is causing me a headache!
      >
      > Any ideas??
      > TIA - Oli[/color]

      Nope. Show us some more of the script. Actually, you should create a test
      page with just the following code in it:

      <%
      dim parm
      parm = Request.Queryst ring("pID")
      Response.Write "parm contains " & parm
      Response.End
      %>

      Run the page, adding the querystring to the url, and let us know if you
      don't get the intended result. If you do get the intended result, start
      adding code from your current page until it stops working. If that does not
      clue you into the problem, show us the code that breaks the page.

      Bob Barrows
      --
      Microsoft MVP - ASP/ASP.NET
      Please reply to the newsgroup. This email account is my spam trap so I
      don't check it very often. If you must reply off-line, then remove the
      "NO SPAM"


      Comment

      • Bob Barrows

        #4
        Re: What's wrong?

        stewert gallington wrote:[color=blue]
        > You've miss spelt querystring as querysting.[/color]

        Good eye! I missed that. (obviously)
        <grin> Of course, you realize that you misspelt "misspelt" ... ;-)
        [color=blue]
        >
        > To avoid this problem you can just refer to it like:
        >
        > request('pID')
        >
        > Its also handy because you can use it to locate a variable anywhere,
        > be it in the querystring or on a form thats submitted.[/color]

        But it can also cause problems:
        1) Performance is impacted because several collections (including the
        servervariables collection - a real performance hit) may have to be searched
        to find the requested variable
        2) You may get the wrong value if your variable name matches one of the
        variable names in another collection. Try getting the result of
        http://...?url=test by using request("url")

        Our recommendation is to always specify the collection you wish to retrieve
        the variable value from.

        Bob Barrows
        --
        Microsoft MVP - ASP/ASP.NET
        Please reply to the newsgroup. This email account is my spam trap so I
        don't check it very often. If you must reply off-line, then remove the
        "NO SPAM"


        Comment

        • Tom B

          #5
          Re: What's wrong?

          In addition to the other comments, I've always used quotes around the item.
          You have apostrophes. I'm not sure if it makes a difference, I've never
          tried.



          "Oli" <oli@NOSPAMoliw oods.co.uk> wrote in message
          news:bqpp0l$1p4 $1@sparta.btint ernet.com...[color=blue]
          > Hi
          >
          > URL in address bar:
          > http://localhost/edituser.asp?pID=1
          >
          > SQLQuery = "SELECT * from Applicant WHERE pID="' &[/color]
          Request.Queryst ing('pID')[color=blue]
          > & '"
          >
          > But it only gets: SELECT * from Applicant WHERE pID=
          >
          > This is only simple but is causing me a headache!
          >
          > Any ideas??
          > TIA - Oli
          >
          >[/color]


          Comment

          • Aaron Bertrand - MVP

            #6
            Re: What's wrong?

            > In addition to the other comments, I've always used quotes around the
            item.[color=blue]
            > You have apostrophes. I'm not sure if it makes a difference, I've never
            > tried.[/color]

            Yes, you should get:

            Microsoft VBScript compilation error '800a03ea'
            Syntax error

            In any case, the reason Oli is getting a blank querystring is because the
            delimiters are all jumbled (spaces added for legibility). The first ' acts
            as a comment, so the rest of the line (after pID=) is ignored.

            "... WHERE pID= " ' & Request.Queryst ing('pID') & ' "

            Should be (note the differences in quotes and apostrophes):

            "... WHERE pID= ' " & Request.Queryst ing("pID") & " ' "


            --
            Aaron Bertrand
            SQL Server MVP
            Please contact this domain's administrator as their DNS Made Easy services have expired.




            Comment

            • TomB

              #7
              Re: What's wrong?

              If I had copied it into my editor, it would have turned green and I would
              have noticed that.

              Good eye Aaron.

              "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
              news:ONwM0M0uDH A.3468@TK2MSFTN GP11.phx.gbl...[color=blue][color=green]
              > > In addition to the other comments, I've always used quotes around the[/color]
              > item.[color=green]
              > > You have apostrophes. I'm not sure if it makes a difference, I've never
              > > tried.[/color]
              >
              > Yes, you should get:
              >
              > Microsoft VBScript compilation error '800a03ea'
              > Syntax error
              >
              > In any case, the reason Oli is getting a blank querystring is because the
              > delimiters are all jumbled (spaces added for legibility). The first '[/color]
              acts[color=blue]
              > as a comment, so the rest of the line (after pID=) is ignored.
              >
              > "... WHERE pID= " ' & Request.Queryst ing('pID') & ' "
              >
              > Should be (note the differences in quotes and apostrophes):
              >
              > "... WHERE pID= ' " & Request.Queryst ing("pID") & " ' "
              >
              >
              > --
              > Aaron Bertrand
              > SQL Server MVP
              > http://www.aspfaq.com/
              >
              >
              >[/color]


              Comment

              • Lakshmi Narayanan

                #8
                What's wrong?

                Dear sir,
                correct the sqlquery as follows
                1). single qoute should come within double qoute
                2). As an expert said spelling mistake in Querystring

                SQLQuery = "SELECT * from Applicant WHERE pID='" &
                Request.Queryst ring('pID') &"'"

                or

                SQLQuery = "SELECT * from Applicant WHERE pID=" &
                Request.Queryst ring('pID')


                I hope this will work.
                [color=blue]
                >-----Original Message-----
                >Hi
                >
                >URL in address bar:
                >http://localhost/edituser.asp?pID=1
                >
                >SQLQuery = "SELECT * from Applicant WHERE pID="' &[/color]
                Request.Queryst ing('pID')[color=blue]
                >& '"
                >
                >But it only gets: SELECT * from Applicant WHERE pID=
                >
                >This is only simple but is causing me a headache!
                >
                >Any ideas??
                >TIA - Oli
                >
                >
                >.
                >[/color]

                Comment

                Working...