Apostrophe, Input Field

Author Message
hcky21

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 7/10/2007
  • Status: offline
Apostrophe, Input Field Tuesday, July 10, 2007 4:55 AM (permalink)
0
Hello,

I am struggling with users typing in an apostrophe in an input field and the VBScript not being able to accept it.

Example:

User inputs a customer name, i.e. O'reily, in a input field
When info is submitted, there is an error because of the apostrophe

This ' is obviously needed because it is a customer's name
how can I work-around this so that the VBScript will accept when info is submitted

thanks for your help.

 
#1
    ebgreen

    • Total Posts : 8219
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: Apostrophe, Input Field Tuesday, July 10, 2007 5:20 AM (permalink)
    0
    Please post your code.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      hcky21

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 7/10/2007
      • Status: offline
      RE: Apostrophe, Input Field Tuesday, July 10, 2007 6:14 AM (permalink)
      0
      To be more specific: the problem is with the City Name, such as Coeur D'Alene

      '5. Prepare ship to address for the listed address.
      If request.querystring("ShipToID") >0 Then
      sqlstr8 = "Select * from AddressBook where ID = '" & request.querystring("ShipToID") & "'"
      Set ors8=conn.execute(sqlstr8)
      End If
       
      #3
        ebgreen

        • Total Posts : 8219
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        RE: Apostrophe, Input Field Tuesday, July 10, 2007 7:20 AM (permalink)
        0
        Aah...so the actual problem is in the query not the VBS itself. I don't remember how to escape ' in SQL but that is what you need to do.
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          ebgreen

          • Total Posts : 8219
          • Scores: 98
          • Reward points : 0
          • Joined: 7/12/2005
          • Status: offline
          RE: Apostrophe, Input Field Tuesday, July 10, 2007 7:22 AM (permalink)
          0
          try this:
           
          sqlstr8 = "Select * from AddressBook where ID = '" & Replace(request.querystring("ShipToID"), "'", "''") & "'"

          "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
          Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
          http://www.visualbasicscript.com/m_47117/tm.htm
           
          #5
            hcky21

            • Total Posts : 4
            • Scores: 0
            • Reward points : 0
            • Joined: 7/10/2007
            • Status: offline
            RE: Apostrophe, Input Field Tuesday, July 10, 2007 7:49 AM (permalink)
            0
            I see, thank for for helping even though it isn't a VBScript issue.  However, it did not work, I am getting this error:


            Microsoft OLE DB Provider for SQL Server error '80040e14'
            Line 1: Incorrect syntax near 'ALENE'.





             
            #6
              ebgreen

              • Total Posts : 8219
              • Scores: 98
              • Reward points : 0
              • Joined: 7/12/2005
              • Status: offline
              RE: Apostrophe, Input Field Tuesday, July 10, 2007 8:42 AM (permalink)
              0
              Basicly you just need to find out how the DB you are querying handles escaping ' then structure your query string accordingly.
              "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
              Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
              http://www.visualbasicscript.com/m_47117/tm.htm
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9