Chức năng: Chuẩn bị giá trị chuổi cho câu lệnh SQL
Ngôn ngữ: asp - Nhóm: database
CÚ PHÁP
string = SQL_String(unformattedstring, maxlength)
Hàm SQL_String chuyển giá trị chuổi về độ dài lớn nhất hoặc giá trị null.
VÍ DỤ
<%
dim a
a = SQL_String("Test string")
%>
ASP Code
<%
Public Function SQL_string(ByVal asExpression, ByRef anMaxLength)
'--- If maximum length is defined
If anMaxLength > 0 Then
'--- Trim expression to maximum length
asExpression = Left(asExpression, anMaxLength)
End If '--- anMaxLength > 0
'--- Double quote SQL quote characters
asExpression = Replace(asExpression, "'", "''")
'--- If Expression is Empty
If asExpression = "" Then
'--- Return a NULL value
SQL_string = "NULL"
'--- Else expression is not empty
Else
'--- Return quoted expression
SQL_string = "'" & CStr(asExpression) & "'"
End If '--- asExpression
End Function '--- SQL_string
%>