2010년 2월 12일 금요일

web 에서 DB 입력 특수문자 처리

Web 에서 DB로 insert 할때 특수 문자 오류가 발생하는 경우가 많다.

 

그래서 기본적인 특수 문자는 변환하여 입력한다.

 

 Function ConvertChar(strValue)

   strValue = trim(strValue)

   strValue = Replace(strValue, "&", "&")

   strValue = Replace(strValue, "<", "<")

   strValue = Replace(strValue, ">", ">")

   strValue = Replace(strValue, "'", "'")

   strValue = Replace(strValue, """", """)

   strValue = Replace(strValue, "|", "|")

   strValue = Replace(strValue, vbCrLf, "<br>")

   ConvertChar = strValue

End Function

<!-- 변경 -->

 

Function DeConvertChar(strValue)

   strValue = Replace(strValue, "&", "&")

   strValue = Replace(strValue, "<", "<")

   strValue = Replace(strValue, ">", ">")

   strValue = Replace(strValue, """, """")

   strValue = Replace(strValue, "'", "'")

   strValue = Replace(strValue, "|","|")

   strValue = Replace(strValue, "<br>",vbCrLf)

   DeConvertChar= strValue

End Function

출처 : Tong - 공원님의 ┣ ★ 먹고사는일(Web)통

댓글 없음:

댓글 쓰기