復(fù)制代碼 代碼如下:
'把字符串轉(zhuǎn)換成數(shù)據(jù)庫SQL語句格式
'-------------------------------------------------
Function AllStr2Database(str,strType)
Dim strTemp:strTemp=str
Select Case strType
Case ""
Case "num"
strTemp = Clng(strTemp)
Case "string" '無Trim
strTemp = Replace(strTemp, "'", "''")
Case "str_br" '無Trim,把回車轉(zhuǎn)換為br>,一般用于多行文本輸入
strTemp = Replace(Replace(strTemp, "'", "''"), VbCrlf, "br>")
Case "str_trim" 'Trim
strTemp = Replace(Trim(strTemp), "'", "''")
Case "nums"
strTemp = Trim(strTemp)
strTemp = Replace(strTemp, ")", "")
strTemp = Replace(strTemp, "(", "")
strTemp = Replace(strTemp, "'", "")
strTemp = Replace(strTemp, ";", "")
strTemp = Replace(strTemp, " ", "")
strTemp = Replace(strTemp, "or", "")
strTemp = Replace(strTemp, "and", "")
strTemp = Replace(strTemp, "delete", "")
strTemp = Replace(strTemp, "select", "")
strTemp = Replace(strTemp, "exec", "")
strTemp = Replace(strTemp, "update", "")
strTemp = Replace(strTemp, "select", "")
Case "strings"
Case Else
End Select
AllStr2Database = strTemp
End Function