Recordset paging headache .....

Discussion in 'ASP General' started by David, Apr 24, 2007.

  1. David

    David Guest

    Hi,

    I have always wanted to get the following working, but have never yet
    mastered it :-(

    I have an asp page which displays a list of records depending on what
    was selected via another form.
    I want to have these results broken down, displaying only 10 records,
    with links underneath to display as
    'Previous' and 'Next'

    _____________________________________________________________

    Firstly I have an include file for the connection which is:

    strConnection = "xxxxxxxxxx"
    Set adoDataConn = Server.CreateObject("ADODB.Connection")
    adoDataConn.Open strConnection

    ______________________________________________________________

    On my actual asp page, I just run the following code and print the
    results on the screen

    strquery = "SELECT * FROM reports ORDER BY ReportID DESC;"
    Set RS = adoDataConn.Execute(strquery)

    If RS.EOF then
    Scream
    Else
    Print Results
    End If
    ______________________________________________________________

    What do I need to do to get this paging working. I have looked at many
    example, but keep running into problems with bookmarks and recordset
    not supporting this and that.

    I would really appreciate any help in geting this working.

    Thanks in advance

    David
    David, Apr 24, 2007
    #1
    1. Advertising

  2. David

    Evertjan. Guest

    David wrote on 24 apr 2007 in microsoft.public.inetserver.asp.general:

    > Hi,
    >
    > I have always wanted to get the following working, but have never yet
    > mastered it :-(
    >
    > I have an asp page which displays a list of records depending on what
    > was selected via another form.
    > I want to have these results broken down, displaying only 10 records,
    > with links underneath to display as
    > 'Previous' and 'Next'
    >
    > _____________________________________________________________
    >
    > Firstly I have an include file for the connection which is:
    >
    > strConnection = "xxxxxxxxxx"
    > Set adoDataConn = Server.CreateObject("ADODB.Connection")
    > adoDataConn.Open strConnection
    >
    > ______________________________________________________________
    >
    > On my actual asp page, I just run the following code and print the
    > results on the screen
    >
    > strquery = "SELECT * FROM reports ORDER BY ReportID DESC;"
    > Set RS = adoDataConn.Execute(strquery)
    >
    > If RS.EOF then
    > Scream
    > Else
    > Print Results
    > End If
    > ______________________________________________________________
    >
    > What do I need to do to get this paging working. I have looked at many
    > example, but keep running into problems with bookmarks and recordset
    > not supporting this and that.
    >
    > I would really appreciate any help in geting this working.


    [If the ReportID is continuous from 0]

    n = request.querysting("n")
    if n="" or n<0 or not IsNumeric(n) then n=0

    sql = "SELECT TOP 10 * FROM reports Where ReportID > "&n&"
    ORDER BY ReportID;"


    <a href='thisfile.asp?n=<% = n-10 %>'>Previous 10</a>
    <a href='thisfile.asp?n=<% = n+10 %>'>Next 10</a>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Apr 24, 2007
    #2
    1. Advertising

  3. David

    David Guest

    Thanks Evertjan,

    I get this error:-

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [MySQL][ODBC 3.51 Driver][mysqld-4.0.20a-max]You have an error in your
    SQL syntax. Check the manual that corresponds to your MySQL server
    version for the right syntax to use near '10 * FROM reports Where
    ReportID >0 ORDER BY ReportID DESC' at

    /Repair_Reports/preview_all.asp, line 85

    ___________________________________________

    I have coded:
    strquery = "SELECT TOP 10 * FROM reports Where ReportID >" & n & "
    ORDER BY ReportID DESC;"





    -----------------------------------------------------------------------------------------------------




    >
    > [If the ReportID is continuous from 0]
    >
    > n = request.querysting("n")
    > if n="" or n<0 or not IsNumeric(n) then n=0
    >
    > sql = "SELECT TOP 10 * FROM reports Where ReportID > "&n&"
    > ORDER BY ReportID;"
    >
    > <a href='thisfile.asp?n=<% = n-10 %>'>Previous 10</a>
    > <a href='thisfile.asp?n=<% = n+10 %>'>Next 10</a>
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
    David, Apr 24, 2007
    #3
  4. David

    Evertjan. Guest

    David wrote on 24 apr 2007 in microsoft.public.inetserver.asp.general:

    >> [If the ReportID is continuous from 0]
    >>
    >> n = request.querysting("n")
    >> if n="" or n<0 or not IsNumeric(n) then n=0
    >>
    >> sql = "SELECT TOP 10 * FROM reports Where ReportID > "&n&"
    >> ORDER BY ReportID;"
    >>
    >> <a href='thisfile.asp?n=<% = n-10 %>'>Previous 10</a>
    >> <a href='thisfile.asp?n=<% = n+10 %>'>Next 10</a>


    [Please do not toppost on usenet]
    [Please do not include signatures in quotes on usenet]

    > I get this error:-


    > [MySQL][ODBC 3.51 Driver][mysqld-4.0.20a-max]You have an error in your
    > SQL syntax. Check the manual that corresponds to your MySQL server
    > version for the right syntax to use near '10 * FROM reports Where
    > ReportID >0 ORDER BY ReportID DESC' at


    > I have coded:
    > strquery = "SELECT TOP 10 * FROM reports Where ReportID >" & n & "
    > ORDER BY ReportID DESC;"


    Not that it explains the error, but the DESC is illogical with
    Where ReportID >" & n & "

    Is ReportID a numeric field ?

    Or it could be that top is not allowed with * in MySQL,
    I never used mySQL under ASP.

    Please report the litteral SQL result resulting from this::

    strquery = "SELECT TOP 10 * FROM reports Where ReportID >" & n & "
    ORDER BY ReportID DESC;"
    response.write strquery
    response.end

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Apr 24, 2007
    #4
  5. David

    David Guest

    Evertjan,

    your code prints:
    SELECT TOP 10 * FROM reports Where ReportID >0 ORDER BY ReportID DESC;

    >>> ReportID is the TableID field (Numeric)


    ------------------------------------------------------------------------------------------------------



    >
    > Not that it explains the error, but the DESC is illogical with
    > Where ReportID >" & n & "
    >
    > Is ReportID a numeric field ?
    >
    > Or it could be that top is not allowed with * in MySQL,
    > I never used mySQL under ASP.
    >
    > Please report the litteral SQL result resulting from this::
    >
    > strquery = "SELECT TOP 10 * FROM reports Where ReportID >" & n & "
    > ORDER BY ReportID DESC;"
    > response.write strquery
    > response.end
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
    David, Apr 24, 2007
    #5
  6. David

    Evertjan. Guest

    David wrote on 24 apr 2007 in microsoft.public.inetserver.asp.general:

    > Evertjan,
    >
    > your code prints:


    Sorry, I do not like topposting on usenet.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Apr 24, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dima

    Recordset Paging between frames

    Dima, Jul 22, 2003, in forum: ASP General
    Replies:
    1
    Views:
    105
    Ray at
    Jul 22, 2003
  2. Hung Huynh
    Replies:
    8
    Views:
    283
    Bob Barrows
    Sep 24, 2003
  3. sara

    recordset paging

    sara, Apr 12, 2005, in forum: ASP General
    Replies:
    3
    Views:
    109
    Bob Barrows [MVP]
    Apr 13, 2005
  4. Ing. Branislav Gerzo

    ADO recordset paging

    Ing. Branislav Gerzo, Jun 24, 2005, in forum: ASP General
    Replies:
    3
    Views:
    137
    Bob Barrows [MVP]
    Jun 24, 2005
  5. David

    Recordset paging headache .....

    David, Apr 24, 2007, in forum: ASP General
    Replies:
    0
    Views:
    91
    David
    Apr 24, 2007
Loading...

Share This Page