UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> FixQuotes    
CODE
' Code courtesy of UtterAccess Wiki
' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary
' July 25, 2010

' DESCRIPTION
' When submitting strings of text for use with SQL,
' it is often required to double any occurances of
' single or double quotes to prevent the SQL string
' from being malformed.

Enum QuoteType
   FixSingleQuotesOnly = 1
   FixDoubleQuotesOnly = 2
   FixSingleAndDoubleQuotes = 3
End Enum

Public Function FixQuotes(StringToFix As String, Optional TypeOfQuotesToFix As QuoteType = 1) As String

   Select Case TypeOfQuotesToFix
       Case 1
           FixQuotes = Replace(StringToFix , "'", "''")
       Case 2
           FixQuotes = Replace(StringToFix , """", """""")
       Case 3
           FixQuotes = Replace(StringToFix , "'", "''")
           FixQuotes = Replace(FixQuotes, """", """""")
   End Select
   
End Function


Creative Commons License
FixQuotes by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 7,008 times.  This page was last modified 21:00, 4 May 2013 by Mark Davis. Contributions by Jack Leach, Walter Niesz and Glenn Lloyd  Disclaimers