Page Disappears

Discussion in 'ASP General' started by Justice75, Jan 28, 2005.

  1. Justice75

    Justice75 Guest

    HI All,

    I am having a problem that is driving me crazy. I have this asp file
    which queries three table sin the db and writes the records. That part
    is fine (process). The page is sorted in ascending order by a field
    inthe db name CYear. The results are crazy. It misses, refuses to pass
    or ignores 7 records. By the way which is the equivalentto one page.
    The page size is divided into 7 records per page. Also, when is fails
    to send the missing records which ARE in the db it doubles some records.
    Meaning a record could be on page 1 but it is also showing up on page 3
    or a record could be on the bottom of page 4 but it also shows up on the
    top of page 5. This thing is KILLING me, please help. The other
    aspects of the page work fine. It is just when we added the sortBy
    function that it all went crazy. Please help. The page is long but
    simple to follow. Any help would be greatly appreciated.

    Thanks,

    Justice


    THE CODE:::

    <%@LANGUAGE="JScript" CODEPAGE="1252"%>
    <%

    //my connection string. you may use yours instead.
    var dbPath,dbName,sConn, strCN;

    //This is your connection string
    var sConn = "dsn=thePartyKidsDB";

    //Create Connection
    var oConn = Server.CreateObject("ADODB.Connection");
    oConn.Open (sConn);

    // This is the page number that supplied by the Flash calling this page.
    var pageNumber = parseInt(Request.Form("pageNumber"));
    //var pageNumber = 2; //comment out

    // This is the school that supplied by the Flash calling this page.
    var eSName = Request.Form("eSName");


    //This is the page size
    var pageSize = 7;

    //This is your actual query
    var tableName = "MemberRegistration INNER JOIN (MemberLogin INNER JOIN
    MemberPreferences ON MemberLogin.MRID = MemberPreferences.MRID) ON
    (MemberLogin.MRID = MemberRegistration.MRID) AND
    (MemberRegistration.MRID = MemberPreferences.MRID)";

    //Your field list
    var fields = "MemberLogin.MRID, MemberLogin.UName,
    MemberRegistration.MRID, \
    MemberRegistration.FFName, MemberRegistration.FNName,
    MemberRegistration.FLName, \
    MemberRegistration.CFName, MemberRegistration.CNName,
    MemberRegistration.CLName, \
    MemberRegistration.ESName, MemberRegistration.ESYear,
    MemberRegistration.MSName, \
    MemberRegistration.MSYear, MemberRegistration.HSName,
    MemberRegistration.HSYear, \
    MemberRegistration.PSName, MemberRegistration.PSYear,
    MemberRegistration.CName, \
    MemberRegistration.CYear, MemberRegistration.OName,
    MemberRegistration.OYear, \
    MemberPreferences.MRID, MemberPreferences.BMonth,
    MemberPreferences.BDate, \
    MemberPreferences.MStatus, MemberPreferences.NKids,
    MemberPreferences.Occupation, \
    MemberPreferences.City, MemberPreferences.State \
    ";
    //your filter clause
    ////////////////////////////////////////////////////////////////////////
    ////////////////
    var queryFilter = "(((MemberRegistration.CName)= '" + eSName + "'))"
    ////////////////////////////////////////////////////////////////////////
    ////////////////
    //Paging query setting
    var primaryKey = "MemberRegistration.MRID";
    var prevString = pageSize * (pageNumber-1);
    //optional sorting (didnt use it)
    //========================================================

    var sortField = "MemberRegistration.CYear";
    var sortDir = "ASC";

    //The Paging query

    var sSQL = "SELECT (SELECT ((COUNT(*) - 1)/" + pageSize + "+ 1) FROM "
    + tableName + " WHERE " + queryFilter + ") AS PageCount,(SELECT
    COUNT(*) FROM " + tableName + " WHERE " + queryFilter + ") AS
    totalCount, " + fields + " \
    FROM " + tableName + " \
    WHERE " + primaryKey + " IN \
    ( \
    SELECT TOP " + pageSize + " " + primaryKey + " \
    FROM " + tableName + " \
    WHERE " + queryFilter
    if (prevString > 0)
    {
    sSQL += " AND " + primaryKey + " NOT IN \
    ( \
    SELECT TOP " + prevString + "
    " + primaryKey + " \
    FROM " + tableName + " \
    WHERE " + queryFilter ;
    if ( sortField )
    {
    sSQL += " ORDER BY "
    + sortField ;
    }
    if ( sortField && sortDir )
    {
    sSQL += " " +
    sortDir ;
    }
    sSQL += " ) " ;
    if ( sortField )
    {
    sSQL += " ORDER BY " + sortField ;
    }
    if ( sortField && sortDir )
    {
    sSQL += " " + sortDir ;
    }
    }
    sSQL += " ) ";
    if ( sortField )
    {
    sSQL += " ORDER BY " + sortField ;
    }
    if ( sortField && sortDir )
    {
    sSQL += " " + sortDir ;
    }

    //opening the recordset
    var rs = Server.CreateObject("ADODB.Recordset");
    with(rs)
    {
    ActiveConnection = oConn;
    CursorType = 3
    CursorLocation = 3;
    LockType = 1
    Source = sSQL;
    Open();
    }

    var strRW = "&";
    //Im not sure if you need the counter now. Do you think that I need the
    counter? Would it give me the total number of records or just the total
    number on the page?
    var numCO = 0;
    totalcounter= rs.Fields("totalCount").Value;
    pagecounter= Math.floor(rs.Fields("PageCount").Value);

    //I can suggest you to get rs fields using: rs.Fields("fieldName").Value
    while( !rs.EOF)
    {
    //In JS, the concatenation is done using the +.
    strRW += "UName" + numCO + "=" + rs.Fields("UName").Value
    + "&BMonth" + numCO + "=" + rs.Fields("BMonth").Value
    + "&BDate" + numCO + "=" + rs.Fields("BDate").Value
    //+ "&BYear" + numCO + "=" + rs.Fields("BYear").Value
    + "&MStatus" + numCO + "=" + rs.Fields("MStatus").Value
    + "&NKids" + numCO + "=" + rs.Fields("NKids").Value
    + "&Occupation" + numCO + "=" +
    rs.Fields("Occupation").Value
    + "&City" + numCO + "=" + rs.Fields("City").Value
    + "&State" + numCO + "=" + rs.Fields("State").Value
    + "&FFName" + numCO + "=" + rs.Fields("FFName").Value
    + "&FNName" + numCO + "=" + rs.Fields("FNName").Value
    + "&FLName" + numCO + "=" + rs.Fields("FLName").Value
    + "&CFName" + numCO + "=" + rs.Fields("CFName").Value
    + "&CNName" + numCO + "=" + rs.Fields("CNName").Value
    + "&CLName" + numCO + "=" + rs.Fields("CLName").Value
    + "&ESName" + numCO + "=" + rs.Fields("ESName").Value
    + "&ESYear" + numCO + "=" + rs.Fields("ESYear").Value
    + "&MSName" + numCO + "=" + rs.Fields("MSName").Value
    + "&MSYear" + numCO + "=" + rs.Fields("MSYear").Value
    + "&HSName" + numCO + "=" + rs.Fields("HSName").Value
    + "&HSYear" + numCO + "=" + rs.Fields("HSYear").Value
    + "&PSName" + numCO + "=" + rs.Fields("PSName").Value
    + "&PSYear" + numCO + "=" + rs.Fields("PSYear").Value
    + "&CName" + numCO + "=" + rs.Fields("CName").Value
    + "&CYear" + numCO + "=" + rs.Fields("CYear").Value
    + "&OName" + numCO + "=" + rs.Fields("OName").Value
    + "&OYear" + numCO + "=" + rs.Fields("OYear").Value + "&"
    //+ "&Total" + numCO + "=" + rs.Fields("totalCount").Value
    // just in case Ive provided that total record count
    //+ "&PageCount" + numCO + "=" +
    Math.floor(rs.Fields("PageCount").Value) + "&" //the page count that
    you need in your Flash
    //+ "&Article" + numCO + "=" + rs.Fields("Article").Value +
    "&"
    ;
    rs.MoveNext();
    numCO++;
    }
    //screen test can I take the line breaks out
    //Response.Write(strRW);

    //I don't think that you need the tot now, since it will alwase show the
    page size - see line 94?
    Response.Write(strRW + "tot=" + numCO + "&"+"tCounter=" + totalcounter +
    "&" + "pCounter=" + pagecounter);

    rs.close();
    rs = null;
    oConn.Close();
    oConn=null;
    %>



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Justice75, Jan 28, 2005
    #1
    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. Robert Zurer

    Page disappears when alert shows?

    Robert Zurer, May 1, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    983
    Alvin Bruney [MVP]
    May 2, 2004
  2. Joel
    Replies:
    1
    Views:
    371
    John Saunders
    Jul 25, 2004
  3. champ0007

    CSS disappears on Reload of ASPX Page

    champ0007, Jun 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,216
    champ0007
    Jun 10, 2005
  4. Darril Gibson
    Replies:
    0
    Views:
    352
    Darril Gibson
    Jun 12, 2006
  5. Darril Gibson
    Replies:
    0
    Views:
    399
    Darril Gibson
    Jun 12, 2006
Loading...

Share This Page