Function returns the formated string which can be used for SQL Server
Function returns the formated string which can be used for SQL Server
Rate Function returns the formated string which can be used for SQL Server
(1(1 Vote))
' 1. strSQLString -> String which has to be formated for SQL
' 2. boolIsName -> Optional. Signifies whether the String passed is a name in SQL or Not
' Function returns the formated string which can be used for SQL Server
' All the characters which are not allowed in Naming the Object in SQL Server
' is removed from the passed string
' The invalid characted for naming are put in a
' constant cnstInValidChars each seperated by a #(Hash)
Private Function CorrectString(strSQLString As String, Optional boolIsName As Boolean) As String
' As specified in SQL
'Const cnstInValidChars = " #*#[#]#\#|#?#<#>#:#""#?#%#."
' As specified in SQL and Some More
Const cnstInValidChars = " #,#--#.#+#-#/#\#|#*#>#<#&#^#(#)#[#]#{#}#:#;#?#~#`#'#!#%#=#"""
Dim strSQL As String
Dim arrChar() As String
Dim intCntr As Integer
strSQL = Replace$(strSQLString, "'", "''", , , vbTextCompare)
' Formating for Object Name
If boolIsName Then
arrChar() = Split(cnstInValidChars, "#", , vbTextCompare)
For intCntr = 0 To UBound(arrChar)
strSQL = Replace$(strSQL, arrChar(intCntr), "", , , vbTextCompare)
Next intCntr
End If
CorrectString = strSQL
End Function
Function returns the formated string which can be used for SQL Server Comments
No comments yet — be the first to post one!
Post a Comment