If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Using "&" in a search string HELP!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-12-02, 16:13
Entcee Entcee is offline
Registered User
 
Join Date: Dec 2002
Posts: 3
Using "&" in a search string HELP!!

We currently have a website that can search an Access database.
The database is our customer list.

The problem I am having is if there is a "&" in the customer name, it does not pull up a record because the sql statement thinks I am trying to find 2 seperate strings instead of one.

In the example below Request.QueryString("CustName")
could = Gary & Co. It tries to find the record where CustName = Gary and also Co not "Gary & Co"

<%
Dim CustomerData__MMColParam
CustomerData__MMColParam = "1"
if (Request.QueryString("CustName") <> "") then CustomerData__MMColParam = Request.QueryString("CustName")
%>
<%
set CustomerData = Server.CreateObject("ADODB.Recordset")
CustomerData.ActiveConnection = MM_QBCustomerData_STRING
CustomerData.Source = "SELECT * FROM QBCustData WHERE CustName = '" + Replace(CustomerData__MMColParam, "'", "''") + "'"
CustomerData.CursorType = 0
CustomerData.CursorLocation = 2
CustomerData.LockType = 3
CustomerData.Open()
CustomerData_numRows = 0
%>

Anyone know a way around this?

Thanks,
Nate
Reply With Quote
  #2 (permalink)  
Old 01-17-03, 16:55
Memnoch1207 Memnoch1207 is offline
Registered User
 
Join Date: Jan 2003
Location: Midwest
Posts: 138
use Server.URLEncode for the customer querystring
Reply With Quote
  #3 (permalink)  
Old 01-18-03, 18:53
Entcee Entcee is offline
Registered User
 
Join Date: Dec 2002
Posts: 3
Quote:
Originally posted by Memnoch1207
use Server.URLEncode for the customer querystring
How would I use it?
Can you put it in my code for me, so I can see where it would go?

Thanks

Nate
Reply With Quote
  #4 (permalink)  
Old 01-20-03, 11:30
Memnoch1207 Memnoch1207 is offline
Registered User
 
Join Date: Jan 2003
Location: Midwest
Posts: 138
if (Request.QueryString("CustName") <> "") then CustomerData__MMColParam = Server.URLEncode(Request.QueryString("CustName"))
Reply With Quote
  #5 (permalink)  
Old 01-20-03, 11:55
Entcee Entcee is offline
Registered User
 
Join Date: Dec 2002
Posts: 3
Thanks a lot!

Nate
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On