Value in recordset changes 2 variables Help

F

ferky

I have this code below when I asign strOldTkinit = strNewTkinit and
then read the new value for the strNewTkinit from the recordset the
strOldTkinit changes the value also. So when I run my comparison the
values is always equal even though I read a new value from the
recordset. Please help.


function getRSXML(strSQL) {
var adoCnn = null;
var adoRst = null;
var strRst = null;
var strReturn = null;
var i=0;
var intPeriod = null;
var intRange = null;
var intPeriodTotal = null;
var intRangeTotal = null;
var intValue = 0;
var strNewTkinit = "";
var strOldTkinit = "";
var strTkName = null;
var strPeriod = 0;
var numberTimes = 0;

strReturn = "";

try {
adoCnn = new ActiveXObject("Webview.clsDatalayer");
adoRst = new ActiveXObject("ADODB.Recordset");


adoRst = adoCnn.Get_RecordSet(strSQL);
//Get the <STATS> Info
strReturn += '<STATS>';
while ((adoRst.EOF == false) && (adoRst.BOF == false)) {


strPeriod = adoRst(2);
intValue = adoRst(5);
if (strNewTkinit == strOldTkinit)
{
//strOldTkinit == strNewTkinit;
//Same timekeeper perform calculations
if (strPeriod == '0804'){ //should be a variable for current
period
intPeriod = intValue;
}
else{
intRange += intValue;
}


}
else // strOldTkinit == strNewTkinit;
{

if (numberTimes == 0)
{
numberTimes ++; // Never again
//strOldTkinit = strNewTkinit;

strTkName = adoRst(3) + ' ' + adoRst(4);

//Same timekeeper perform calculations
if (strPeriod == '0804'){ //should be a variable for current
period
intPeriod = intValue;
}
else{
intRange += intValue;
}

}
else
{
//If new timekeeper print current line
i++;
strReturn += '<z r=\"'+ i +'\" c1=\"'+ strOldTkinit +'\"
c2=\"'+ strTkName +'\" c3=\"'+ intPeriod +'\" c4=\"'+ intRange +'\"
/>';

//Calculate values for the <STATSFOOTER>
intPeriodTotal += intPeriod;
intRangeTotal += intRange;

//strOldTkinit = strNewTkinit;
trTkName = adoRst(3) + ' ' + adoRst(4);

if (strPeriod == '0804'){ //should be a variable for current
period
intPeriod = intValue;
}
else{
intRange += intValue;
}

}

}


adoRst.movenext;
strOldTkinit = strNewTkinit;

}

i++;
strReturn += '<z r=\"'+ i +'\" c1=\"'+ strOldTkinit +'\" c2=\"'+
strTkName +'\" c3=\"'+ intPeriod +'\" c4=\"'+ intRange +'\" />';

//Calculate values for the <STATSFOOTER>
intPeriodTotal += intPeriod;
intRangeTotal += intRange;

strReturn += '</STATS><STATSFOOTER>';
//<z r="397" c1="" c2="GRAND TOTAL" c3="-7169.50"
c4="175414250.54" />
strReturn += '<z r=\"'+ numberTimes +'\" c1=\"\" c2=\"GRAND TOTAL\"
c3=\"'+ intPeriodTotal +'\" c4=\"'+ intRangeTotal +'\" />';
strReturn += '</STATSFOOTER>';


} catch (DBErr) {
strReturn = "DBErr" + DBErr.message;
} finally {
try {
adoRst.Close();
} catch (CloseErr){}

adoCnn = null;
adoRst = null;
strRst = null;
}
return strReturn;
}
 
L

Lee

ferky said:
I have this code below when I asign strOldTkinit = strNewTkinit and
then read the new value for the strNewTkinit from the recordset the
strOldTkinit changes the value also. So when I run my comparison the
values is always equal even though I read a new value from the
recordset. Please help.

Within all of the code you posted, the only value ever assigned
to strNewTkinit is "", so it seems like you haven't shown us the
important code.

However, your symptom sounds like strNewTkinit is being set to the
reference to an Object. In that case, setting strOldTkinit will
set that variable to refer to the *same Object*, so changing the
attributes of either one is seen in both. What to do to fix that
depends on what sort of Object is involved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top