Click to See Complete Forum and Search --> : SQL Query help w/ special characters


dirt29
11-09-2006, 10:29 AM
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?

so_is_this
11-09-2006, 10:35 AM
Put the string in single quotes:

selection = "Texas A&M"
sql = "Select * from myTable Where selection = '" & selection & "';"

dirt29
11-09-2006, 11:03 AM
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.


<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:


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?