473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Page Disappears

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!
Jul 22 '05 #1
0 1113

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin Zuber | last post by:
Hello, I have found following problem: When I define event handler for EVT_NOTEBOOK_PAGE_CHANGED for wxNotebook, the content of the wxNotebook disappears (on all pages). For ex. I have two pages...
6
by: Les Juby | last post by:
I'm trying to print a simple catalogue of products but where an image straddles a page break, the image either disappears completely or else the first half prints at the bottom of the page but the...
0
by: | last post by:
hi, selected items in check box disappears when submit button is clicked on aspx page. check box is pasted on .ascx page and which is pasted on aspx page any ideals cheers sam
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
5
by: Maxim Izbrodin | last post by:
Hello For displaying page titles for my ASP.NET applications I use the following technique <title><%=BannerModule.PageTitle%></title where BannerModule.PageTitle is a public field of my user...
4
by: Robert Zurer | last post by:
When I click a Button server control I want two things to happen. The server returns a string array of error messages. A Javascript alert appears showing the errors. I can do this using the...
2
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate...
3
by: Antonio | last post by:
I would like to create a FAQ feature for my web page that populates from a table in the sql server. My table would have a column for a question and one for answer. On the web page I would like to...
2
by: Vishal Gupta | last post by:
Hi all, I have a placeholder control on an ASPX page. I dynamically add a few button control and label control to the placeholder from code - all is well with the world. But on post back the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.