函数实现数据库操作部分

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

转载于:https://www.cnblogs.com/oosumu/archive/2004/12/29/83417.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值