Advertisement

11.16.2004 at 07:02AM PST, ID: 21208506
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

ASP JS get current month and convert values

Asked by Justice75 in Active Server Pages (ASP)

Tags: , ,

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.BMonth=)" +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.Connection");
oConn.Open (sConn);

//get Flash
//var pageNumber = parseInt(Request.Form("pageNumber"));

//Create Connection
var oConn = Server.CreateObject("ADODB.Connection");
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.BMonth)='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").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 += "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").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;

%>
Start Free Trial
[+][-]11.16.2004 at 08:03AM PST, ID: 12594958

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2004 at 09:11AM PST, ID: 12595806

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2004 at 09:24AM PST, ID: 12595949

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2004 at 11:23AM PST, ID: 12597175

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: asp, from, select
Sign Up Now!
Solution Provided By: Colosseo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]11.16.2004 at 11:47AM PST, ID: 12597403

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2004 at 11:52AM PST, ID: 12597439

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2004 at 11:59AM PST, ID: 12597509

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32