|
dzirkelb1 -> Cleaning Up Data Requests from a Form (11/3/2009 12:03:40)
|
We all know the pesty things users can do, and the pesty things databases fail on (like quotes, blank values for numbers opposed to null, spaces, etc). So, i created this little function I have on my include page:
Function CleanDataStr(strData)
i = 1
if len(strData) > 0 then
do while i <= len(strData)
if mid(strData, i, 1) = Chr(34) Or mid(strData, i, 1) = Chr(39) then
if i > 1 then
strLeftText = left(strData, i - 1)
else
strLeftText = ""
end if
if i < len(strData) then
strRightText = right(strData, len(strData) - i)
else
strRightText = ""
end if
strData = strLeftText & strRightText
else
i = i + 1
end if
loop
end if
CleanDataStr = Trim(strData)
End Function
Function CleanDataInt(intData)
if intData = "" or len(intData) = 0 then
intData = "NULL"
end if
CleanDataInt = intData
End Function
Anyone else have stuff to add to it? This should take care of ", empty spaces, and makes blank values a Null.
|
|
|
|