Results 1 to 4 of 4

Thread: Those damn quotation marks

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89

    Angry

    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

  2. #2
    Guest
    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.


  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Azzmodan is correct, you need to replace single quotes with 2 single quotes

    use the replace function

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

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    89
    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
  •  



Click Here to Expand Forum to Full Width