www.webdeveloper.com
Results 1 to 3 of 3

Thread: SQL Query help w/ special characters

  1. #1
    Join Date
    Aug 2005
    Location
    USA
    Posts
    116

    SQL Query help w/ special characters

    If I am trying to pass an & into a sql query, but I can't seem to get it to work.

    For example, if I have a school name like "Texas A&M", how do you get it to recoginize the ampersand as part of the string?

  2. #2
    Join Date
    Oct 2006
    Posts
    1,297
    Put the string in single quotes:
    Code:
    selection = "Texas A&M"
    sql = "Select * from myTable Where selection = '" & selection & "';"

  3. #3
    Join Date
    Aug 2005
    Location
    USA
    Posts
    116
    Thats what I tried initially, but that doesn't help.

    See what I'm trying to do is, excute a search query based off of a passed parameter from a drop down menu.

    Let me provide my code, as maybe it will make more sense what exactly is happening. I think the issue is not with the search query, but the passed value is not right. Let me explain.

    Code:
    <OPTION style="width: 100px;" VALUE="shopsearch.asp?search=yes&Exact=<%=rs("pother1")%>"><%= rs("pother1") %></option>
    This is the code from the dynamic dropdown...it passes if this is a search and the exact word to search for. However, I noticed in my browser bar, when I select for example Texas A&M, in the bar it puts this:

    Code:
    http://www.babyfanatic.com/shopdisplayproducts.asp?Search=Yes&sppp=10exact=Texas%20A
    The &M after Texas A&M is not parsed. I forget, but isn't there a way to wrap this, URLEncode or something like that?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles