|
-
Jun 27th, 2000, 04:05 AM
#1
Thread Starter
Lively Member
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
#2
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.
-
Jun 27th, 2000, 11:44 AM
#3
Guru
Azzmodan is correct, you need to replace single quotes with 2 single quotes
use the replace function
strNewString = replace(strString, "'", "''")
-
Jun 28th, 2000, 01:00 AM
#4
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|