<
%
'
用子函数实现数据库操作部分
dim cmdTest, rsTest,prmTest
' 函数ADOEXEC0处理存储过程不需要调用参数的情况
function ADOEXEC0(ComText)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC1处理存储过程需调用一个参数的情况
function ADOEXEC1(ComText,InputStr)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
Set prmTest = cmdTest.CreateParameter( " teplace1 " ,adVarChar,adParamInput, 500 ,InputStr)
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC2处理存储过程需调用两个参数的情况
function ADOEXEC2(ComText,InputStr1,inputstr2)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
Set prmTest = cmdTest.CreateParameter( " teplace1 " ,adVarChar,adParamInput, 500 ,InputStr1)
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
Set prmTest = cmdTest.CreateParameter( " teplace2 " ,adVarChar,adParamInput, 500 ,InputStr2)
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC处理存储过程需调用多个参数的情况
function ADOEXEC(ComText,n,arrpra)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
for i = 0 to n - 1
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
next
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC_OUT处理存储过程需返回参数的情况
function ADOEXEC_OUT(ComText,n,arrpra)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
set prmTest = cmdTest.CreateParameter( " returncode " ,adInteger,adParamReturnValue)
cmdTest.Parameters.Append prmTest
for i = 0 to n - 1
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
next
Set cmdTest.ActiveConnection = conn
cmdTest. Execute
end function
' 函数ADOEXEC处理存储过程需调用多个参数及参数长度较大的情况
function ADOEXECX(ComText,n,arrpra,m)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
for i = 0 to n - 1
' m是大数据的数组位,表示这个数组元素的值是大数据
if i = m then
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 1000000000 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
else
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
end if
next
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC处理存储过程需调用多个参数的情况,用于分页
function ADOEXEC_Page(ComText,n,arrpra)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
for i = 0 to n - 1
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
next
Set cmdTest.ActiveConnection = conn
Set rstest = Server. CreateObject ( " ADODB.Recordset " )
rstest.Open cmdTest, , 1 , 3
end function
' 函数ADOlink处理调用sql语句的情况
function ADOlink(sqlstr)
' 创建数据集对象rstest
Set rstest = Server. CreateObject ( " ADODB.Recordset " )
' 用Rs对象.open方法执行SQL。
rstest.Open sqlstr,conn, 1 , 1
end function
' 释放数据集对象rstest
sub endRecordSet()
rstest.close
set rstest = nothing
end sub
' 显示错误提示信息
sub ShowErrMsg(errMsg)
response.write " <SCRIPT language=""VBScript"">msgbox "" " & errMsg & " "",64,""注意!""</Script>"
end sub
' 检查输入字符串中是否含有'字符,有则转换
function CheckStr(str)
dim tstr,l,i,ch
l = len (str)
for i = 1 to l
ch = mid (str,i, 1 )
if ch = " ' " then
tstr = tstr + " '"
end if
tstr = tstr + ch
next
CheckStr = tstr
end function
' 用于输入大段文字的字符检查
function changechr(str)
changechr = replace ( replace (str, " <img src= " , " [sayyes] " ), " ></img> " , " [/sayyes] " )
changechr = replace ( replace ( replace ( replace (changechr, " < " , " < " ), " > " , " > " ), chr ( 13 ), " <br> " ), " " , " " )
' changechr=replace(replace(replace(replace(changechr,"[sayyes]","<img src="),"[b]","<b>"),"[red]","<font color=CC0000>"),"[big]","<font size=7>")
' changechr=replace(replace(replace(replace(changechr,"[/sayyes]","></img>"),"[/b]","</b>"),"[/red]","</font>"),"[/big]","</font>")
end function
' 用于输出大段文字的字符检查(textarea)
function changechrBack(str)
changechrBack = replace ( replace ( replace ( replace (str, " < " , " < " ), " > " , " > " ), " <br> " , chr ( 13 )), " " , " " )
changechrBack = replace ( replace (changechrBack, " [sayyes] " , " <img src= " ), " [/sayyes] " , " ></img> " )
end function
' 用于输出大段文字的字符检查(response)——输出变换1
function changechrBack1(str)
changechrBack1 = replace ( replace ( replace (str, " < " , " < " ), " > " , " > " ), " <br> " , chr ( 13 ))
changechrBack1 = replace ( replace (changechrBack1, " [sayyes] " , " <img src= " ), " [/sayyes] " , " ></img> " )
end function
function htmlencode(str)
htmlencode = replace ( replace (str, chr ( 13 ), " <br> " ), " ' " , " '' " )
end function
' 用函数showpage1来显示页面跳转
function showpage1(totalnumber,maxperpage,filename)
' 求出当每页n篇文章时总共的页数
dim n
if totalnumber mod maxperpage = 0 then
n = totalnumber \ maxperpage
else
n = totalnumber \ maxperpage + 1
end if
response.write " <form method=Post action= " & filename & " > "
response.write " <p align='center'> "
' 显示页数链接的条件
if CurrentPage < 2 then
response.write " <font color='#000080'>首页 上一页</font> "
else
response.write " <a href= " & filename & " ?page=1>首页</a> "
response.write " <a href= " & filename & " ?page= " & CurrentPage - 1 & " >上一页</a> "
end if
if n - currentpage < 1 then
response.write " <font color='#000080'>下一页 尾页</font> "
else
response.write " <a href= " & filename & " ?page= " & (CurrentPage + 1 ) & " >下一页</a> "
response.write " <a href= " & filename & " ?page= " & n & " >尾页</a> "
end if
response.write " <font color='#000080'> 页次:</font><strong><font color=red> " & CurrentPage & " </font><font color='#000080'>/ " & n & " </strong>页</font> "
response.write " <font color='#000080'> 共<b> " & totalnumber & " </b>条记录 <b> " & maxperpage & " </b>条记录/页</font> "
response.write " <font color='#000080' size=2>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value= " & currentpage & " > "
response.write " <input class=buttonface type='submit' value='Goto' name='cndok'></span></p></form> "
end function
% >
dim cmdTest, rsTest,prmTest
' 函数ADOEXEC0处理存储过程不需要调用参数的情况
function ADOEXEC0(ComText)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC1处理存储过程需调用一个参数的情况
function ADOEXEC1(ComText,InputStr)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
Set prmTest = cmdTest.CreateParameter( " teplace1 " ,adVarChar,adParamInput, 500 ,InputStr)
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC2处理存储过程需调用两个参数的情况
function ADOEXEC2(ComText,InputStr1,inputstr2)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
Set prmTest = cmdTest.CreateParameter( " teplace1 " ,adVarChar,adParamInput, 500 ,InputStr1)
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
Set prmTest = cmdTest.CreateParameter( " teplace2 " ,adVarChar,adParamInput, 500 ,InputStr2)
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC处理存储过程需调用多个参数的情况
function ADOEXEC(ComText,n,arrpra)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
for i = 0 to n - 1
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
next
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC_OUT处理存储过程需返回参数的情况
function ADOEXEC_OUT(ComText,n,arrpra)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
set prmTest = cmdTest.CreateParameter( " returncode " ,adInteger,adParamReturnValue)
cmdTest.Parameters.Append prmTest
for i = 0 to n - 1
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
next
Set cmdTest.ActiveConnection = conn
cmdTest. Execute
end function
' 函数ADOEXEC处理存储过程需调用多个参数及参数长度较大的情况
function ADOEXECX(ComText,n,arrpra,m)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
for i = 0 to n - 1
' m是大数据的数组位,表示这个数组元素的值是大数据
if i = m then
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 1000000000 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
else
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
end if
next
Set cmdTest.ActiveConnection = conn
Set rsTest = cmdTest. Execute
end function
' 函数ADOEXEC处理存储过程需调用多个参数的情况,用于分页
function ADOEXEC_Page(ComText,n,arrpra)
Set cmdTest = Server. CreateObject ( " ADODB.Command " )
cmdTest.CommandText = ComText
' 设命令类型为 存储过程
cmdTest.CommandType = adCmdStoredProc
for i = 0 to n - 1
Set prmTest = cmdTest.CreateParameter(i,adVarChar,adParamInput, 500 ,arrpra(i))
' 将数据追加到 Parameters 数据集合中
cmdTest.Parameters.Append prmTest
next
Set cmdTest.ActiveConnection = conn
Set rstest = Server. CreateObject ( " ADODB.Recordset " )
rstest.Open cmdTest, , 1 , 3
end function
' 函数ADOlink处理调用sql语句的情况
function ADOlink(sqlstr)
' 创建数据集对象rstest
Set rstest = Server. CreateObject ( " ADODB.Recordset " )
' 用Rs对象.open方法执行SQL。
rstest.Open sqlstr,conn, 1 , 1
end function
' 释放数据集对象rstest
sub endRecordSet()
rstest.close
set rstest = nothing
end sub
' 显示错误提示信息
sub ShowErrMsg(errMsg)
response.write " <SCRIPT language=""VBScript"">msgbox "" " & errMsg & " "",64,""注意!""</Script>"
end sub
' 检查输入字符串中是否含有'字符,有则转换
function CheckStr(str)
dim tstr,l,i,ch
l = len (str)
for i = 1 to l
ch = mid (str,i, 1 )
if ch = " ' " then
tstr = tstr + " '"
end if
tstr = tstr + ch
next
CheckStr = tstr
end function
' 用于输入大段文字的字符检查
function changechr(str)
changechr = replace ( replace (str, " <img src= " , " [sayyes] " ), " ></img> " , " [/sayyes] " )
changechr = replace ( replace ( replace ( replace (changechr, " < " , " < " ), " > " , " > " ), chr ( 13 ), " <br> " ), " " , " " )
' changechr=replace(replace(replace(replace(changechr,"[sayyes]","<img src="),"[b]","<b>"),"[red]","<font color=CC0000>"),"[big]","<font size=7>")
' changechr=replace(replace(replace(replace(changechr,"[/sayyes]","></img>"),"[/b]","</b>"),"[/red]","</font>"),"[/big]","</font>")
end function
' 用于输出大段文字的字符检查(textarea)
function changechrBack(str)
changechrBack = replace ( replace ( replace ( replace (str, " < " , " < " ), " > " , " > " ), " <br> " , chr ( 13 )), " " , " " )
changechrBack = replace ( replace (changechrBack, " [sayyes] " , " <img src= " ), " [/sayyes] " , " ></img> " )
end function
' 用于输出大段文字的字符检查(response)——输出变换1
function changechrBack1(str)
changechrBack1 = replace ( replace ( replace (str, " < " , " < " ), " > " , " > " ), " <br> " , chr ( 13 ))
changechrBack1 = replace ( replace (changechrBack1, " [sayyes] " , " <img src= " ), " [/sayyes] " , " ></img> " )
end function
function htmlencode(str)
htmlencode = replace ( replace (str, chr ( 13 ), " <br> " ), " ' " , " '' " )
end function
' 用函数showpage1来显示页面跳转
function showpage1(totalnumber,maxperpage,filename)
' 求出当每页n篇文章时总共的页数
dim n
if totalnumber mod maxperpage = 0 then
n = totalnumber \ maxperpage
else
n = totalnumber \ maxperpage + 1
end if
response.write " <form method=Post action= " & filename & " > "
response.write " <p align='center'> "
' 显示页数链接的条件
if CurrentPage < 2 then
response.write " <font color='#000080'>首页 上一页</font> "
else
response.write " <a href= " & filename & " ?page=1>首页</a> "
response.write " <a href= " & filename & " ?page= " & CurrentPage - 1 & " >上一页</a> "
end if
if n - currentpage < 1 then
response.write " <font color='#000080'>下一页 尾页</font> "
else
response.write " <a href= " & filename & " ?page= " & (CurrentPage + 1 ) & " >下一页</a> "
response.write " <a href= " & filename & " ?page= " & n & " >尾页</a> "
end if
response.write " <font color='#000080'> 页次:</font><strong><font color=red> " & CurrentPage & " </font><font color='#000080'>/ " & n & " </strong>页</font> "
response.write " <font color='#000080'> 共<b> " & totalnumber & " </b>条记录 <b> " & maxperpage & " </b>条记录/页</font> "
response.write " <font color='#000080' size=2>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value= " & currentpage & " > "
response.write " <input class=buttonface type='submit' value='Goto' name='cndok'></span></p></form> "
end function
% >