UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> FunctionLibrary:FixQuotes    
CODE
' 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(sql As String, Optional TypeOfQuotesToFix As QuoteType = 1) As String

   Select Case TypeOfQuotesToFix
       Case 1
           FixQuotes = Replace(sql, "'", "''")
       Case 2
           FixQuotes = Replace(sql, """", """""")
       Case 3
           FixQuotes = Replace(sql, "'", "''")
           FixQuotes = Replace(FixQuotes, """", """""")
   End Select
   
End Function
Edit Discussion
Custom Search


Thank you for your support!
This page has been accessed 1,533 times.  This page was last modified 22:05, 25 July 2010 by Walter Niesz.   Disclaimers