Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Posts
    3

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

  2. #2
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    use Server.URLEncode for the customer querystring

  3. #3
    Join Date
    Dec 2002
    Posts
    3
    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

  4. #4
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    if (Request.QueryString("CustName") <> "") then CustomerData__MMColParam = Server.URLEncode(Request.QueryString("CustName"))

  5. #5
    Join Date
    Dec 2002
    Posts
    3
    Thanks a lot!

    Nate

Posting Permissions

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