Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Page Disappears

Reply
Thread Tools

Page Disappears

 
 
Justice75
Guest
Posts: n/a
 
      01-28-2005
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Data Set disappears on second page load Darril Gibson ASP .Net 0 06-12-2006 12:55 AM
Session Data Set disappears on second page load Darril Gibson ASP .Net 0 06-12-2006 12:48 AM
CSS disappears on Reload of ASPX Page champ0007 ASP .Net 0 06-10-2005 05:11 AM
Page object disappears inside event handler Joel ASP .Net 1 07-25-2004 08:13 PM
Page disappears when alert shows? Robert Zurer ASP .Net 4 05-02-2004 04:00 PM



Advertisments