Passing a string with '%'

Results 1 to 3 of 3

Thread: Passing a string with '%'

  1. #1
    Loto Guest

    Default Passing a string with '%'

    From my file: test1.asp<BR>when clicking on a button I call the same file: test1.asp and send a string as a parameter. <BR>If this string (strSQL) is like: "SELECT * FROM TABLE1" , then I have no problems.<BR>But.... if the string is like:<BR>"SELECT * FROM TABLE1 WHERE Field1 LIKE &#039%&#039 ",<BR>then, clicking the button does NOTHING!!!<BR>I am afraid it is AGAIN a problem with the quotes and single quotes!!!!!!!<BR>How can I sort it out???<BR><BR>&#060;INPUT TYPE=BUTTON VALUE=Next onCLICK="document.location.href=&#039test1.asp?MyS tring=&#060;%=strSQL&#062;&#039"&#062;<BR>

  2. #2
    Amanda Bennett Guest

    Default RE: Passing a string with '%'

    One thing I notice about the sample of html you submitted is that you did not include a closing % delimeter at the end of your "strSQL" variable. If this is just a typo in the question you submitted, then I would try assigning your sql string to a Javascript variable, as opposed to an ASP variable, since it is Javascript you are using in the click event of this button. For example, you could type this in between your Javascript tags:<BR>funtion passURL() {<BR>var strSQL = "SELECT * FROM TABLE1 WHERE Field1 LIKE &#039%&#039 "<BR>document.location.href = "test1.asp?MyString=" + strSQL<BR>}<BR>and then when you try to call this function in the click event of the button:<BR>&#060;INPUT TYPE=BUTTON VALUE=Next onCLICK="javascript:passURL()"&#062;

  3. #3
    Join Date
    Dec 1969

    Default RE: Passing a string with '%'

    You need to Server.URLEncode() your string first.<BR><BR>BTW, passing raw SQL isn&#039t a great idea, especially not by querystring. What happens if I edit the URL so that the SQL is a DROP DATABASE statement instead of a SELECT?<BR><BR>Dunc

Posting Permissions

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