加菲猫

博客园 首页 新随笔 联系 订阅 管理
                                                ado parameter command
1:
infoid=request("infoid")
 set conn=server.createobject("adodb.connection")
 conn.open  connstring  
 sql="select  * from test where id=?"
 Set cmd = CreateObject("ADODB.Command")                            
cmd.ActiveConnection = conn
cmd.CommandText = sql                                 
cmd.CommandType = 1    ' 1 means adCmdText
cmd.Prepared = true 
cmd.Parameters.Append cmd.CreateParameter("", adVarChar, adParamInput,150,infoid)
set rs=cmd.execute
2:

infoid=request("infoid")
 set conn=server.createobject("adodb.connection")
 conn.open  connstring  
 sql="select  * from test where id>?"
 Set cmd = server.CreateObject("ADODB.Command")
                            
cmd.ActiveConnection = conn
cmd.CommandText = sql                                
cmd.CommandType = 1    ' 1 means adCmdText
cmd.Prepared = true                             
cmd.Parameters.Append cmd.CreateParameter("p1", adVarChar, adParamInput,150,infoid)
set rs=server.CreateObject("adodb.recordset")
rs.CursorLocation = adUseClient
       
rs.open cmd
pagesize=2
curpage=1
 if not rs.eof then
    infocount=rs.RecordCount
         rs.PageSize=pagesize
         pagecount=rs.PageCount
         if cint(curpage)>pagecount then
        curpage=cstr(pagecount)
         end if
         rs.AbsolutePage=cint(curpage)
         do while (not rs.EOF) and (i<pagesize)
             i=i+1 
         response.write rs("name")
         rs.movenext
       loop
                
    end if             
  conn.close


3:

 infoid=request("infoid")
 set conn=server.createobject("adodb.connection")
 conn.open  connstring
 conn.execute "update test set  name='bjh' where name='tt'"
 sql="select  * from test where name like '%' + ? +'%' or name like '%'+?+'%'"
 Set cmd = server.CreateObject("ADODB.Command")                            
cmd.ActiveConnection = conn
cmd.CommandText = sql                                 
cmd.CommandType = 1    ' 1 means adCmdText
cmd.Prepared = true 
                            
cmd.Parameters.Append cmd.CreateParameter("@p1", adVarChar, adParamInput,150,infoid)
cmd.Parameters.Append cmd.CreateParameter("@p2", adVarChar, adParamInput,150,infoid)
     

set rs=server.CreateObject("adodb.recordset")
rs.CursorLocation = adUseClient
      
rs.open cmd
pagesize=2
curpage=1
response.write rs.eof
 if not rs.eof then
    infocount=rs.RecordCount
         rs.PageSize=pagesize
         pagecount=rs.PageCount
         if cint(curpage)>pagecount then
        curpage=cstr(pagecount)
         end if
         rs.AbsolutePage=cint(curpage)
         do while (not rs.EOF) and (i<pagesize)
             i=i+1 
         response.write rs("name")
         rs.movenext
       loop
                
    end if             
  conn.close

4:
 sqlstr="exec pagination3 'bgt','id,title,ifcheck,putdate','id',"&pagesize&","&curpage&",1,1,"&chr(34)&querystr&chr(34)&""     set cn=server.CreateObject("ADODB.Connection")
    cn.ConnectionString=Application("connstr")
    cn.Open
    set rs=server.CreateObject("adodb.recordset")
    rs.CursorLocation = 3
    rs.CursorType=3
    rs.ActiveConnection=cn
    rs.Open sqlstr
    infocount=rs("infocount")
    set rs=rs.NextRecordset()
    if infocount>0 then
          If infocount mod pagesize = 0 Then
               pagecount=infocount\pagesize
          Else
              pagecount = cint(infocount\pagesize) +1
          End If
        
          do while (not rs.EOF) 
             i=i+1
              if (i mod 2)=0 then
                response.write "<tr bgcolor='#e2edf7'>"
              else
                response.write "<tr bgcolor='#fffeee'> "
               end if 
              response.write "</tr>"
              rs.MoveNext
          loop

    end if
    rs.Close()
    cn.Close()


posted on 2008-06-10 09:18  bjh  阅读(537)  评论(0编辑  收藏  举报