PDA

Click to See Complete Forum and Search --> : Those damn quotation marks


scottr
Jun 27th, 2000, 04:05 AM
hey guy another question:

I have a text field on my web page. The problem is that when i type a single quote(') it recoginzies it as the end of the string and i get an error message that i didnt properly end my sql statement. However if i take it out it works like a charm. What do people do in a situation like this, would i have to write a function to strip those out, the problem with that is that im afraid i will lose the formating when the user brings up the text field again. I have to maintain formating. Any suggestion would be greatly appreciated.

regards,

Scott

Jun 27th, 2000, 05:16 AM
U could use "'s instead of ''s but that will give you a problem when they enter a ".

The correct way i believe is to replace the ' with 2 ''s. Then i should add the value without problems.

Clunietp
Jun 27th, 2000, 11:44 AM
Azzmodan is correct, you need to replace single quotes with 2 single quotes

use the replace function

strNewString = replace(strString, "'", "''")

scottr
Jun 28th, 2000, 01:00 AM
here is another fucntion too

Public Function ConvertString(myString As String) As String
Dim i As Integer
If InStr(myString, "'") Then
ConvertString = ""
For i = 1 To Len(myString)
ConvertString = ConvertString & Mid(myString, i, 1)
If Mid(myString, i, 1) = "'" Then ConvertString = ConvertString & "'"
Next i
Else
ConvertString = myString
End If