'' Returns a text suitable for SQL queries, removes line breaks and characters not compatible with SQL statements.
Static Public Function Chek4SQL(strInput As String) As String
Dim strOutput As String
strOutput = Replace(strInput, Chr(92) & Chr(110), ":")
strOutput = Replace(strOutput, Chr(34), "")
strOutput = Replace(strOutput, "\n", " ")
strOutput = Replace(strOutput, "\r", "")
strOutput = Replace(strOutput, "\x00", "")
strOutput = Replace(strOutput, Chr(39), Chr(46))
strOutput = Replace(strOutput, Chr(44), Chr(46))
Return strOutput
End
Static Public Function Chek4SQL(strInput As String) As String
Dim strOutput As String
Dim aForbiden, aReplacement As New String[]
Dim n As Integer
aForbiden = [Chr(92) & Chr(110), Chr(34), "\n", "\r", "\x00", Chr(39), Chr(44)]
aReplacement = [";", "", " ", "", "", Chr(46), Chr(46)]
strOutput = strInput
For n = 0 To aForbiden.Max
strOutput = Replace(strOutput, aForbiden[n], aReplacement[n])
Next
Return strOutput
End
(12-08-2021, 18:32)tincho escribió:También, también...(12-08-2021, 18:14)Shordi escribió: Sin que sea mejor ni peor, sólo porque yo tengo como fobia a esas chorrileras de instrucciones iguales, lo hubiese escrito así:
Si, es otra forma valida de hacerlo, pero viniendo de ti esperaba una "Collection"
Saludos.