Hi All,
I have a quick probem and it is very sisular to the problem that I had last. I am having a problem with line 38. It reads:
var queryFilter = "MemberPreferences.BMonth=
" + inMo
In the database 11 is a string not a numeric value. Is there anyway that I can convert the value of the field once in the ASP page. For instance on the request.form we can use code such as:
var inID = CInt(Request.Form("ID"))
Is there anything that we can use on the db query with a SELECT statement or after. An example page is below. In this example I would like the value of inMO to be compared to the current month in a mm(two digit format). I am not sure how to get the current month or compare values. Such as (pseudo):
var inMO = getDate(mm);
var queryFilter = CInt("MemberPreferences.BM
onth=)" +inMO
Sorry about the lack of experience. I hope that you get my logic. Thanks for any help from anyone.
Justice
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=theParty";
//Create Connection
var oConn = Server.CreateObject("ADODB
.Connectio
n");
oConn.Open (sConn);
//get Flash
//var pageNumber = parseInt(Request.Form("pag
eNumber"))
;
//Create Connection
var oConn = Server.CreateObject("ADODB
.Connectio
n");
oConn.Open (sConn);
// This is the page number that supplied by the Flash calling this page. //is this suppose to be a passed variable as in the query string
var pageNumber = 1; //comment out
//This is the page size
var pageSize = 6;
//This is your actual query
var tableName = "MemberLogin INNER JOIN MemberRegistration INNER JOIN MemberPreferences ON MemberRegistration.MRID = MemberPreferences.MRID ON MemberLogin.MRID = MemberPreferences.MRID";
//Your field list
var fields = "MemberLogin.*, MemberPreferences.*, MemberRegistration.*";
//your filter clause
//var queryFilter = "((MemberPreferences.BMont
h)='11')"
var inMo = '11';
// THIS IS THE LINE THAT IS CAUSING ME A PROBLEM///////////////////
//////////
///
var queryFilter = "MemberPreferences.BMonth=
" + inMo
//Paging query setting
var primaryKey = "MemberPreferences.MRID";
var prevString = pageSize * (pageNumber-1);
//optional sorting (didnt use it)
var sortField = "MemberPreferences.MRID";
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 + " \
\
) " ;
}
sSQL += " ) ";
//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").Va
lue;
pagecounter= Math.floor(rs.Fields("Page
Count").Va
lue);
//I can suggest you to get rs fields using: rs.Fields("fieldName").Val
ue
while( !rs.EOF)
{
//In JS, the concatenation is done using the +.
strRW += "MRID" + numCO + "=" + rs.Fields("MRID").Value
+ "&BMonth" + numCO + "=" + rs.Fields("BMonth").Value
+ "&BDate" + numCO + "=" + rs.Fields("BDate").Value
+ "&FFName" + numCO + "=" + rs.Fields("FFName").Value
+ "&FNName" + numCO + "=" + rs.Fields("FNName").Value
+ "&FLName" + numCO + "=" + rs.Fields("FLName").Value
//+ "&Total" + numCO + "=" + rs.Fields("totalCount").Va
lue // just in case Ive provided that total record count
//+ "&PageCount" + numCO + "=" + Math.floor(rs.Fields("Page
Count").Va
lue) //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;
%>
Start Free Trial