paging with ADODB.Command and Recordsets


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: paging with ADODB.Command and Recordsets

  1. #1
    CybersparkS Guest

    paging with ADODB.Command and Recordsets


    I need help, I need to use paging or similar for a ADODB.Command that turns
    into a recordset script...

    I will explain more...

    I need my page to have a list of 10 records displayed, at the top it will
    say 1 - 10 of 26, then will show a list of records from a database 10 at
    a time with next page and previous page links.

    Below is my script to search the database, I would appreciate it if someone
    could modify it for me to do this, or tell me how I could do it

    Thanks...

    <% Option Explicit
    Dim strConnect
    %>

    <!-- #Include File = "Connections/Datastore.asp"-->
    <!-- MetaData Type = "TypeLib" File="C:\Program Files\Common Files\System\ado\msado15.dll"-->


    <html>
    <head>
    <title>Reptiles</title>
    </head>


    <body>


    <%

    Dim objCommand, objRS

    Set objCommand = Server.CreateObject("ADODB.Command")

    objCommand.ActiveConnection = strConnect
    objCommand.CommandText = "SELECT * FROM AllData " &_
    "WHERE Person LIKE '%" & Request.Form("Rept") & "%' "

    objCommand.CommandType = adCmdText

    Set objRS = objCommand.Execute
    Set objCommand = Nothing

    If objRS.EOF Then
    Response.write "That is not available"
    Else

    Response.write "<table border=1>"
    Response.write "<tr><td>ID Number</td><td>Lister</td><td>Reptile</td>"
    & "<td>Open File</td></tr>"
    While Not objRS.EOF
    Response.write "<tr><td>" & objRS("ID") & "</td><td>" & objRS("Listers")
    & "</td><td>" & objRS("Reptile") & "</td><td>Open</td></tr>"
    objRS.MoveNext
    Wend
    End If


    objRS.Close
    Set objRS = Nothing
    %>


    </table>

    </body>
    </html>

  2. #2
    Dejan Lukovic Guest

    Re: paging with ADODB.Command and Recordsets


    I think that it's much better to create ADODB.Connection object
    set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open(connection string)
    after that create rs like ADODB.Recordset object on same way

    then set

    rs.ActiveConnection = oConn
    rs.PageSize = 10
    rs.CacheSize = 10
    rs.CursorLocation = 3 (adUseClient) this line is most important here because
    with this line you got all of records from database on local maschine and
    than you can uce CountRecords property of recordset but before you must specify
    rs.Source = "SELECT .... "
    rs.Open
    nNumberOfRecords = rs.RecordCount
    nNumberOfPages = rs.PageCount

    I hope that I'm help you

    Dejan Lukovic
    Delegate Software
    AT Vienna

    nNumberOfRecords = rs.CountRecord

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center