<
%
' '-------------------------------------------------------------------
' '创建一个可以更新的RS对象
' function GetRS(conn,table,where,orderby)
' '测试objRS是否有纪录,有就返回true
' function ChkRS(objRS)
' '根据条件Where返回指定表table的属性Attribute的值
' function GetAttr(conn,table,where,attribute)
' '截取字符串
' Function LeftStr(ByVal Str, ByVal MaxLength)
' '得到字符长度
' Function CountLength(Str)
' '安全获取ID
' function RstInt(strID)
' '-------------------------------------------------------------------
' 创建一个可以更新的RS对象
function GetRS(conn,table,where,orderby)
set rs = server.CreateObject( " adodb.recordset " )
if orderby <> "" then orderby = " order by " & orderby
if where <> "" then where = " where " & where
rs.open " select * from " & table & where & orderby,conn, 1 , 3
set GetRS = rs
end function
' 测试objRS是否有纪录,有就返回true
function ChkRS(objRS)
if not objRS.bof and not objRS.eof then
ChkRS = true
else
ChkRS = false
end if
end function
' 根据条件Where返回指定表table的属性Attribute的值
function GetAttr(conn,table,where,attribute)
if where <> "" then where = " where " & where
set rsAttr = conn.execute( " select " & attribute & " from " & table & where)
if not rsAttr.bof and not rsAttr.eof then
GetAttr = rsAttr(attribute)
else
GetAttr = " -1 "
end if
end function
' 截取字符串
Function LeftStr(ByVal Str, ByVal MaxLength)
Dim Output,i
If IsNull (Str) Then Str = ""
Output = ""
If LenB(Str) <= MaxLength Then
Output = Str
Else
For i = 1 To Len (Str)
Output = Output & Mid (Str,i, 1 )
If CountLength(Output) + 3 = MaxLength Then
Output = Output & " ... "
Exit For
ElseIf CountLength(Output) + 3 > MaxLength Then
Output = Left (Output, Len (Output) - 1 ) & " ... "
Exit For
End If
Next
End If
LeftStr = Output
End Function
' 得到字符长度
Function CountLength(Str)
Dim output,ThisChar,i
output = 0
For i = 1 To Len (Str)
ThisChar = Mid (Str,i, 1 )
If Asc (ThisChar) < 0 Then
output = output + 2
Else
output = output + 1
End If
Next
CountLength = output
End Function
' 安全获取ID
function RstInt(strID)
Dim regex ' 声明变量
Set regex = New RegExp ' 创建对象
ID = request(strID)
regex.Pattern = " ^[0-9]+$ "
If regex.Test(ID) Then
RstInt = ID
Else
RstInt =- 1
End If
end function
% >
' '-------------------------------------------------------------------
' '创建一个可以更新的RS对象
' function GetRS(conn,table,where,orderby)
' '测试objRS是否有纪录,有就返回true
' function ChkRS(objRS)
' '根据条件Where返回指定表table的属性Attribute的值
' function GetAttr(conn,table,where,attribute)
' '截取字符串
' Function LeftStr(ByVal Str, ByVal MaxLength)
' '得到字符长度
' Function CountLength(Str)
' '安全获取ID
' function RstInt(strID)
' '-------------------------------------------------------------------
' 创建一个可以更新的RS对象
function GetRS(conn,table,where,orderby)
set rs = server.CreateObject( " adodb.recordset " )
if orderby <> "" then orderby = " order by " & orderby
if where <> "" then where = " where " & where
rs.open " select * from " & table & where & orderby,conn, 1 , 3
set GetRS = rs
end function
' 测试objRS是否有纪录,有就返回true
function ChkRS(objRS)
if not objRS.bof and not objRS.eof then
ChkRS = true
else
ChkRS = false
end if
end function
' 根据条件Where返回指定表table的属性Attribute的值
function GetAttr(conn,table,where,attribute)
if where <> "" then where = " where " & where
set rsAttr = conn.execute( " select " & attribute & " from " & table & where)
if not rsAttr.bof and not rsAttr.eof then
GetAttr = rsAttr(attribute)
else
GetAttr = " -1 "
end if
end function
' 截取字符串
Function LeftStr(ByVal Str, ByVal MaxLength)
Dim Output,i
If IsNull (Str) Then Str = ""
Output = ""
If LenB(Str) <= MaxLength Then
Output = Str
Else
For i = 1 To Len (Str)
Output = Output & Mid (Str,i, 1 )
If CountLength(Output) + 3 = MaxLength Then
Output = Output & " ... "
Exit For
ElseIf CountLength(Output) + 3 > MaxLength Then
Output = Left (Output, Len (Output) - 1 ) & " ... "
Exit For
End If
Next
End If
LeftStr = Output
End Function
' 得到字符长度
Function CountLength(Str)
Dim output,ThisChar,i
output = 0
For i = 1 To Len (Str)
ThisChar = Mid (Str,i, 1 )
If Asc (ThisChar) < 0 Then
output = output + 2
Else
output = output + 1
End If
Next
CountLength = output
End Function
' 安全获取ID
function RstInt(strID)
Dim regex ' 声明变量
Set regex = New RegExp ' 创建对象
ID = request(strID)
regex.Pattern = " ^[0-9]+$ "
If regex.Test(ID) Then
RstInt = ID
Else
RstInt =- 1
End If
end function
% >