how to handle single quotation marks

N

new

Just wonder how you guys handle the single quatation marks when you
write the value of a text input into SQL server. Thanks!

* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.
 
S

solex

I wrote a replaceall function to handle this problem and create a DLL with
common string functions:

Function ReplaceAll(ByVal Buffer As String, ByVal FindWhat As String, _
ByVal ReplaceWith As String) As Variant
'
' Replaces all instances of FindWhat with ReplaceWith in the
' buffer
'
Dim intLenFind As Integer
Dim intLenReplace As Integer
Dim intPos As Integer

If Len(Buffer) = 0 Then
ReplaceAll = ""
Else
intLenFind = Len(FindWhat)
intLenReplace = Len(ReplaceWith)

intPos = 1
Do
intPos = InStr(intPos, Buffer, FindWhat)
If intPos > 0 Then
Buffer = Left(Buffer, intPos - 1) & _
ReplaceWith & Mid(Buffer, intPos + intLenFind)
intPos = intPos + intLenReplace
End If
Loop Until intPos = 0
End If

ReplaceAll = Buffer

End Function
 
A

Aaron Bertrand - MVP

I was doing a similar thing, by replacing ' to something like @#$% :)

And then switching it back again, in every single application that connects
to that table? Ick...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top