part of sqlstring coming from QueryString with an %

Results 1 to 3 of 3

Thread: part of sqlstring coming from QueryString with an %

  1. #1
    Ricardo Rocha Guest

    Default part of sqlstring coming from QueryString with an %

    Ok, here&#039s my problem...<BR>I want to have an sqlstring searching records on a table...<BR>something like this: "Select * FROM table WHERE name LIKE &#039A%&#039"<BR>This would give me all the names starting with A...<BR>But what i want is to have the name coming from the querystryng... this part is working...<BR>But then i want to have the &#039A%&#039 also coming from the QueryString...<BR>I&#039ve tried something like Request.QueryString("string") where the querystring would have a field string=&#039A%&#039<BR>doesn&#039t work!!<BR>i&#039ve tried A% only...<BR>the only way is to have only the A on the querystring and to put the % on the sqltring directly.... but that&#039s not what i want<BR>here&#039s the error i get!!<BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e14&#039 <BR>[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression &#039nome LIKE &#039Að/LM/W3SVC/1/Root/FCP_OnLine&#039. <BR><BR>and here is the resultant sqlstring:<BR>SELECT * FROM listaemails WHERE nome LIKE &#039Að/LM/W3SVC/1/Root/FCP_OnLine<BR><BR>hope from some help<BR>

  2. #2
    Nathan Pond Guest

    Default RE: part of sqlstring coming from QueryString with an %

    The problem is that the % is a special character to querystrings, along with the ampersand (&) and plus sign (+). The percent sign is followed by 2 digits that specifies a character. The digits are the hexidecimal ascii code for the character. So if you want a % to transfer through the querystring, you need to put it in as:<BR><BR>%25<BR><BR>25 being the hex ascii code of the percent sign.<BR><BR>There is also an ASP function that will format strings to be able to be passed in QueryStrings. So in your case:<BR><BR>StringToPass = "A%"<BR>StringToPass = Server.UrlEncode(StringToPass)<BR><BR>Then it will be formatted correctly. Hope I helped<BR><BR>Nathan

  3. #3
    Ricardo Rocha Guest

    Default RE: part of sqlstring coming from QueryString with an %

    It did...<BR>Thanks a lot!!!

Posting Permissions

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