If you look up VBScript functions you will find things like the trim function (removes leading and traling white space) however the other two are simple ones I have written. I keep these in a global functions file, include it in all the pages and call then where neccesary. They are:
Function StoreText(theText)
StoreText = ""
on error resume next
StoreText = CStr(theText)
if (len(StoreText) > 0) Then
StoreText = Replace(StoreText, """", """, 1, -1, 1)
StoreText = Replace(StoreText, "'", "''", 1, -1, 1)
StoreText = Replace(StoreText, vbCrLf, "<BR>", 1, -1, 1)
end if
End Function
This function simply uses the replace function to change ' to '' and vbCrLf to <bR> etc. I wrap this function around ALL strings going nto my DB
Here is the amDate function:
FUNCTION amDate(varDate)
IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
amDate = "Null"
ELSE
amDate = "" & Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & ""
END IF
END FUNCTION
This simply uses the dateValue, day, month and year functions to ensure what ever valid date is passed goes into the DB as dd/mm/yyyy
use them like so:
myFieldName='" & trim(storeText(request.form("myFormElementName"))) & "'
myFieldName=#" & amdate(request.form("myFormElementName"))) ) & "#" (into ACCESS)
myFieldName='" & amdate(request.form("myFormElementName"))) ) & "'" (into SQLServer)
Wind is your friend
Matt
www.elitemarquees.com.au