PDA

Click to See Complete Forum and Search --> : Escape characters


Nov 3rd, 2000, 07:28 AM
Hi, I was wondering if someone has written a routine that helps me write data to and get data from my SQL Server database, so that it won't give an error. Hmm.. that was not very clear. Let me clarify myself using an example:

My home town is called 's-Hertogenbosch. When I want to write this as a string to the database, I first have to replace the leading ' by a double ' so that in the database, the field is filled with the value 's-Hertogenbosch. So far, so good.

Now I want to retrieve the data from the database and show it in a textbox, and it shows me an empty textbox, since the leading ' causes it to think the string is over. Here's the code:

<%
if blnAmILoggedIn then
response.write("<input type='text' name='City' size='30' value='" & RS_MYDATA.fields.item("City").value & "'>")
else
response.write("<input type='text' name='City' size='30'>")
end if
%>

In this code, if I get 's-Hertogenbosch from the database, it won't work. Does anyone know how I can easily check/convert all values that I get from the database, so it will display the correct string? I know what to do to get 's-Hertogenbosch into the database, just not how I can show it properly once I have retrieved it again.

Any help is more than welcome. Thanx! :)

ShIzO
Nov 3rd, 2000, 11:03 AM
when using:


...size='30' value='" & RS_MYDATA.fields.item("City").value & "'>")


use


size='30' value=" & chr(34) & " & RS_MYDATA.fields.item("City").value & chr(34) & ">")


this will put your string within double quote.

Nov 6th, 2000, 02:30 AM
Okay, that works fine for the example I gave...
But now if I want to save the text 'People used to call me "shorty" in highschool' and then I want to display it again in the textbox, it shows me: 'People used to call me' since it cuts it off after the double quotes.

Any ideas?