View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Michel Pierron Michel Pierron is offline
external usenet poster
 
Posts: 214
Default Storing appostrophe's in SQL

Hi Jeff,
for example:
Function FixApostrophy(ByVal sSQL As String) As String
Dim sPhrase As String, wLength As Integer, m As Integer
wLength = Len(sSQL)
For m = 1 To wLength
If Mid(sSQL, m, 1) = "'" Then
sPhrase = sPhrase & "''"
Else
sPhrase = sPhrase & Mid(sSQL, m, 1)
End If
Next
FixApostrophy = sPhrase
End Function

MP

"Jeff" a écrit dans le message de
...
I have a text box that allows the user to type in free
form text. I want to save it to a SQLServer database
table. If the user types in <Here's Johnny!, I can insert
it into SQLServer by inserting the text string <Here''s
Johnny!

My question: is there a function that does this, or do I
process the text string before I insert it to double all
the appostrophe's?

Thanks!