Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with sql statement

    I get this message when I try to run my code:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'pj'.

    /projectors/Test2.asp, line 19


    Here is the code:

    Code:
    <%
    Response.Buffer = True
    
       ' projector to retrieve
       Dim pj
          pj = Request("ProjectorList")
          
    
       ' Connection String
       Dim connStr
          connStr = "dsn=myyrroad;uid=c5558;pwd=7688900;network=dbmssocn"
    
       ' Recordset Object
       Dim rs
          Set rs = Server.CreateObject("ADODB.Recordset")
          
          ' opening connection
          rs.Open "select * from screenshots where ProjectorName = pj", connStr, 3, 4
             
     
    %>
    <html>
    
    
    <body>
    <%
    t = rs("Screen")
    Response.Write("t")
    rs.Close
    Set rs = Nothing
    Set connStr = Nothing
    %>
    </body>
    
    </html>
    I would appreciate any help

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    rs.Open "select * from screenshots where ProjectorName = '" & replace(pj,"'","''") & "'", connStr, 3, 4

    See the sticky post regarding escaping single quotes.

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Glen, Thanks a million


  •  

    Posting Permissions

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