<%
Function ProcCmd(docount)
'建一个command对象
set CmdSP = Server.CreateObject("ADODB.Command")

'建立连结
CmdSP.ActiveConnection =Conn

'定义command 对象调用名称 
CmdSP.CommandText = "PageView"

'设置command调用类型是存储过程 (adCmdSPStoredProc = 4)
CmdSP.CommandType = adCmdSPStoredProc
'
Set objPara=CmdSP.CreateParameter("@tblName", adVarChar, adParamInput,255,tblName)
CmdSP.Parameters.Append objPara

Set objPara=CmdSP.CreateParameter("@strGetFields", adVarChar, adParamInput,1000,strGetFields)
CmdSP.Parameters.Append objPara

Set objPara=CmdSP.CreateParameter("@fldName", adVarChar, adParamInput,255,fldName)
CmdSP.Parameters.Append objPara

Set objPara=CmdSP.CreateParameter("@pagesize", adInteger, adParaminput,4 ,intpagesize)
CmdSP.Parameters.Append objPara

Set objPara=CmdSP.CreateParameter("@pageindex", adInteger, adParaminput, 4,currentPage)
CmdSP.Parameters.Append objPara


Set objPara=CmdSP.CreateParameter("@docount", adInteger, adParaminput,4 ,docount)
CmdSP.Parameters.Append objPara

Set objPara=CmdSP.CreateParameter("@OrderType", adInteger, adParamInput,4,OrderType)
CmdSP.Parameters.Append objPara

Set objPara=CmdSP.CreateParameter("@strWhere", adVarChar, adParamInput,1500,strWhere)
CmdSP.Parameters.Append objPara


'执行存储过程
If docount=1 Then
   Set Rss = CmdSP.Execute
   ProcCmd=Rss("Total")
   
Else
   Set Rs = CmdSP.Execute
   ProcCmd=Rs
End If
End Function
%>
<%    adCmdSPStoredProc = 4
adParamReturnValue = 4
adParaminput = 1
adParamOutput = 2
adInteger = 3
adVarChar = 200    Const MaxPerPage=20
If Not isempty(request("page")) Then
currentPage=Cint(request("page"))
Else
currentPage=1
End If  Sql="Sh=1"
If AnclassId<>"" And AnclassId<>0 Then Sql=Sql&" And AnclassId="&AnclassId
If Nclassid<>"" Then Sql=Sql&" And Nclassid="&Nclassid
If bclassid<>"" Then Sql=Sql&" And bclassid="&bclassid
If sclassid<>"" Then Sql=Sql&" And sclassid="&sclassid
Sql=Sql&" And (Mc Like '%"&Key&"%' Or Wz Like '%"&Key&"%' Or Jj Like '%"&Key&"%') "
intpagesize=MaxPerPage
docount=0
tblName="Chwl"
strGetFields="Id,Rate,AnclassId,Anclass,Nclass,BclassId,Mc,Dh,Wz,Jj,Fbsj"
fldName="Id"
OrderType=1   '1为降序
strWhere=Sql


ProcCmd(0)

If not Rs.eof Then
TotalPut=ProcCmd(1)
If CurrentPage<1 Then
CurrentPage=1
End If
If (CurrentPage-1)*MaxPerPage>Totalput Then
If (totalPut mod MaxPerPage)=0 Then
CurrentPage= TotalPut \ MaxPerPage
Else
CurrentPage= TotalPut \ MaxPerPage + 1
End If
End If
Go="?Rate="&Rate&"&AnclassId="&AnclassId&"&Nclassid="&Nclassid&"&Bclassid="&Bclassid&"&Sclassid="&Sclassid&"&Key="&Key
  End If %>帮助写出sql存储过程!谢谢!有高手加我QQ410589588