ASP / SQL Question

Discussion in 'ASP General' started by NetZeroUser, Aug 27, 2004.

  1. NetZeroUser

    NetZeroUser Guest

    Quick question for the NG.

    I have the following on my ASP page. SchPN is actually grabbed from a text
    box, but here is what I am entering

    schPN = "PRT"
    strsql = "select PrinterModel, UserName, PrinterName, PrinterType,
    IP_Address from Printers where (PrinterName LIKE '%schPN%')"

    I would assume that this would pull all printers from my Access DB that
    contain the words PRT, but it doesn't.

    Any ideas?
    Thanks
     
    NetZeroUser, Aug 27, 2004
    #1
    1. Advertising

  2. You have the literal text "schPN" in your SQL query. I don't think this is
    what you wanted.

    Try:

    ' schPN = Replace(Request.Form("schPN"), "'", "''")
    schPN = "PRT"
    strsql = "SELECT ... WHERE PrinterName LIKE '%" & schPN & "%'"

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "NetZeroUser" <> wrote in message
    news:...
    > Quick question for the NG.
    >
    > I have the following on my ASP page. SchPN is actually grabbed from a

    text
    > box, but here is what I am entering
    >
    > schPN = "PRT"
    > strsql = "select PrinterModel, UserName, PrinterName, PrinterType,
    > IP_Address from Printers where (PrinterName LIKE '%schPN%')"
    >
    > I would assume that this would pull all printers from my Access DB that
    > contain the words PRT, but it doesn't.
    >
    > Any ideas?
    > Thanks
    >
    >
     
    Aaron [SQL Server MVP], Aug 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ecoolone
    Replies:
    0
    Views:
    765
    ecoolone
    Jan 3, 2008
  2. Jules
    Replies:
    6
    Views:
    154
    Jules
    Jul 15, 2003
  3. Ed Garcia
    Replies:
    4
    Views:
    190
    Guinness Mann
    Aug 7, 2003
  4. Belinda
    Replies:
    4
    Views:
    365
    Bob Barrows [MVP]
    Jun 11, 2004
  5. weiwei

    asp and sql statement in sql server db

    weiwei, Sep 22, 2004, in forum: ASP General
    Replies:
    3
    Views:
    206
    Jeff Cochran
    Sep 22, 2004
Loading...

Share This Page