I have modified dataread.asp to simply read the rows from the database and put them in an array. But it still crashed. :(
I found out that the problem is related to the database access in the dataread.asp. I found that out by only executed the updatedb.asp once to load up the database table. The dataread.asp page continued to read the same data from the database table. It crashed just like before. So, I believe the problem isn't in the updatedb.asp. Then, I modified your roundtripIframe code to refresh itself just like my code below. Your page refreshed just fine for a long time. This is why I determined that the problem is related to the access to the database in the dataread.asp.
If you look at the database access in the dataread.asp, it's very straighforward and it ran just fine by itself. But somehow, it didn't go well with the rest of the javascript.
Here is the file that invokes the dataread.asp and updatedb.asp. I used updatedb.asp to update the database. This updatedb.asp page uses the META to refresh itself every 5 seconds. I put it in a hidden frame and runs in the background. At the same time, I used dataread.asp to read this database table into an Array. The page that invokes both of these asp pages are below. I also included the updatedb.asp and dataread.asp in this reply.
<html>
<head>
<style type="text/css">
<!--
#UpdateTable { position: absolute; visibility: hidden}
#oTableContainer { position: absolute; visibility: hidden }
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function UpdateTab() {
var UpdateTable = document.getElementById('UpdateTable');
UpdateTable.src = "updatedb.asp";
}
function GetTable() {
if (timerEnabled == true)
{
timerEnabled = false;
var oTableContainer = document.getElementById('oTableContainer');
oTableContainer.src = "dataread.asp";
timerEnabled = true;
timerID = setTimeout("GetTable()", 5000);
}
}
function ReceiveData(response)
{
var table = document.getElementById('results');
var oldTbody = table.getElementsByTagName('tbody')[0];
var newTbody = document.createElement('tbody');
table.replaceChild(newTbody, oldTbody);
var table = document.getElementById('results');
var oldTbody = table.getElementsByTagName('tbody')[0];
var newTbody = document.createElement('tbody');
table.replaceChild(newTbody, oldTbody);
for (var i=0, istop=response.length; i<istop; i++) {
var tempRow = document.createElement('tr');
for (var j=0, jstop=response[i].length; j<jstop; j++) {
var tempCell = document.createElement('td');
var tempText = document.createTextNode(response[i][j]);
tempCell.appendChild(tempText);
tempRow.appendChild(tempCell);
}
newTbody.appendChild(tempRow);
}
}
//-->
</script>
</head>
<body>
<center>
<H3 id="h3">
</H3>
<table id="results" border="1">
<thead>
</thead>
<tbody>
</tbody>
</table>
<iframe src="blank2.html" name="UpdateTable" id="UpdateTable"></iframe>
<iframe src="blank.html" name="oTableContainer" id="oTableContainer"></iframe>
</center>
<script type="text/javascript" language="JavaScript">
<!--
timerEnabled = true;
UpdateTab();
GetTable();
//-->
</script>
</body>
</html>
Here is the dataread.asp:
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
function HiMom() {
var reply = new Array();
var ind = 0;
<%
userid = Session("USERID")
odbc1 = Session("ODBC1")
tablename = userid & ".traffic"
Set connectTTDB = Server.CreateObject("ADODB.Connection")
myTTDB = "DSN=" & odbc1
connectTTDB.Open myTTDB
Set TTdbRowset = Server.CreateObject("ADODB.Recordset")
QStr= "select svcname, Last_Rate, Current_Rate, Current_Total, abandcnt from " & tablename & " where deleteind = 0;"
TTdbRowset.Open QStr, connectTTDB, 1, 3
while not TTdbRowset.EOF
svcname = TTdbRowset("svcname")
lastrate = TTdbRowset("Last_Rate")
currate = TTdbRowset("Current_Rate")
curtotal = TTdbRowset("Current_Total")
abandcnt = TTdbRowset("abandcnt")
%>
reply[ind] = new Array();
reply[ind] [0] = '<%=svcname%>';
reply[ind] [1] = <%=lastrate%>;
reply[ind] [2] = <%=currate%>;
reply[ind] [3] = <%=curtotal%>;
reply[ind] [4] = <%=abandcnt%>;
ind = ind + 1;
<%
TTdbRowset.MoveNext
wend
TTdbRowset.Close
connectTTDB.Close
set connectTTDB = Nothing
%>
window.parent.ReceiveData(reply);
}
onload = HiMom;
//-->
</script>
</head>
<body></body>
</html>
Here is the updatedb.asp:
<HTML>
<HEAD>
<META HTTP-EQUIV="REFRESH" Content="5;URL=updatedb.asp">
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
</HEAD>
<BODY>
<center>
<%
Response.Buffer = "True"
userid = Session("USERID")
callsvc = Request.Form("callsvc")
joblist= Request.Form("joblist")
addr = request.servervariables("LOCAL_ADDR")
odbc1 = Session("ODBC1")
odbc2 = Session("ODBC2")
starttime = Session("STARTTIME")
histodbc = Session("HISTODBC")
histuserid = Session("HISTUSERID")
histpasswd = Session("HISTPASSWD")
newinterval = 0
Session("TIMER") = Session("TIMER") + 5
tablename = userid & ".traffic"
Set TTdbRowset1 = Server.CreateObject("ADODB.Recordset")
Set TTdbRowset2 = Server.CreateObject("ADODB.Recordset")
Set connectTTDB = Server.CreateObject("ADODB.Connection")
myTTDB = "DSN=" & odbc1
connectTTDB.Open myTTDB
Set TTdbRowset = Server.CreateObject("ADODB.Recordset")
if odbc2 <> "" then
Set connectTTDB2 = Server.CreateObject("ADODB.Connection")
myTTDB2 = "DSN=" & odbc2
connectTTDB2.Open myTTDB2
end if
Set connectORADB = Server.CreateObject("ADODB.Connection")
' myORADB = "DSN=ic613; UID=oadba; PWD=oadba"
myORADB = "DSN=" & histodbc & "; UID=" & histuserid & "; PWD=" & histpasswd
connectORADB.Open myORADB
Set ORAdbRowset = Server.CreateObject("ADODB.Recordset")
if Session("LOADTBL") = 1 then
Session("LOADTBL") = 0
dim ipos, isrch, strfound
if callsvc <> "" then
dim svcs(), isvcsize, isvcnum
isvcnum = 0
isvcsize = 5
redim svcs(isvcsize)
ipos = 1
isrch = instr(ipos, callsvc, ",")
do while not isrch = 0
strfound = Mid(callsvc, ipos, isrch - ipos)
trim(strfound)
svcs(isvcnum) = strfound
isvcnum = isvcnum + 1
if isvcnum = isvcsize then
isvcsize = isvcsize + 5
redim preserve svcs(isvcsize)
end if
ipos = isrch + 2
isrch = instr(ipos, callsvc, ",")
loop
svcs(isvcnum) = trim(Mid(callsvc, ipos, len(callsvc)-ipos+1))
for i = 0 to isvcnum
QStr1= "select svcid from " & tablename & " where svcid ='" & svcs(i) & "' and channelid <> 0;"
' response.write QStr1
TTdbRowset.Open QStr1, connectTTDB, 1, 3
if not TTdbRowset.EOF then
QStr2= "update " & tablename & " set deleteind=0 where svcid ='" & svcs(i) & "' and channelid <> 0;"
connectTTDB.Execute QStr2
end if
TTdbRowset.Close
next
end if
if joblist <> "" then
dim jobs(), ijobsize, ijobnum
ijobnum = 0
ijobsize = 5
redim jobs(ijobsize)
ipos = 1
isrch = instr(ipos, joblist, ",")
do while not isrch = 0
strfound = Mid(joblist, ipos, isrch - ipos)
trim(strfound)
jobs(ijobnum) = strfound
ijobnum= ijobnum + 1
if ijobnum= ijobsize then
ijobsize = ijobsize + 5
redim preserve jobs(ijobsize)
end if
ipos = isrch + 2
isrch = instr(ipos, joblist, ",")
loop
strfound = Mid(joblist, ipos, len(joblist)-ipos+1)
jobs(ijobnum) = trim(strfound)
for i = 0 to ijobnum
QStr1= "select svcid from " & tablename & " where svcid='" & jobs(i) & "' and channelid = 0;"
TTdbRowset.Open QStr1, connectTTDB, 1, 3
if not TTdbRowset.EOF then
QStr2= "update " & tablename & " set deleteind=0 where svcid='" & jobs(i) & "' and channelid = 0;"
connectTTDB.Execute QStr2
end if
TTdbRowset.Close
next
end if
QStr2= "delete from " & tablename & " where deleteind=1;"
connectTTDB.Execute QStr2
' response.write "DAILYCNT=" & Session("DAILYCNT")
starthour = starttime / 100
if starthour < 10 then
starthour= "0" & starthour
end if
if Session("DAILYCNT") > 1 then
for j = 1 to (Session("DAILYCNT") - 1)
JobDailyTot = 0
DailyTot = 0
if j = 1 then
yesterday_rowdate = Session("DAY1")
else
if j = 2 then
yesterday_rowdate = Session("DAY2")
else
if j = 3 then
yesterday_rowdate = Session("DAY3")
else
if j = 4 then
yesterday_rowdate = Session("DAY4")
else
if j = 5 then
yesterday_rowdate = Session("DAY5")
else
if j = 6 then
yesterday_rowdate = Session("DAY6")
end if
end if
end if
end if
end if
end if
today_rowdate = dateadd("d", 1, yesterday_rowdate)
if month(today_rowdate) < 10 then
rowmonth = "0" & month(today_rowdate)
else
rowmonth = month(today_rowdate)
end if
if day(today_rowdate) < 10 then
rowday = "0" & day(today_rowdate)
else
rowday = day(today_rowdate)
end if
today_rowdate = year(today_rowdate) & rowmonth & rowday & starthour
if month(yesterday_rowdate) < 10 then
rowmonth = "0" & month(yesterday_rowdate)
else
rowmonth = month(yesterday_rowdate)
end if
if day(yesterday_rowdate) < 10 then
rowday = "0" & day(yesterday_rowdate)
else
rowday = day(yesterday_rowdate)
end if
yesterday_rowdate = year(yesterday_rowdate) & rowmonth & rowday & starthour
QStr= "select svcid, channelid from " & tablename & ";"
TTdbRowset.Open QStr, connectTTDB, 1, 3
while not TTdbRowset.EOF
svc1 = TTdbRowset("svcid")
svc1 = rtrim(svc1)
channel = TTdbRowset("channelid")
if channel <> 0 then
QStr = "select sum(wkarrivedcnt) tot from hsvcclasssummary where svcclassid='" & svc1 & "' and (((RowDate = " & yesterday_rowdate & ") AND (StartTime = " & starttime & ")) OR ((RowDate = " & today_rowdate & ") AND (StartTime < " & starttime & ")) OR ((RowDate >= " & yesterday_rowdate & ") AND (RowDate < " & today_rowdate & ")))"
' response.write QStr
ORAdbRowset.Open QStr, connectORADB, 1, 3
if not (ORAdbRowset.EOF and ORAdbRowset.BOF) then
tot = ORAdbRowset("tot")
if tot > 0 then
if channel = 2 then
QStr2= "update " & tablename & " set d" & j & "_CallRate=" & tot & " where svcid='" & svc1 & "' and channelid = 2;"
else if channel = 5 then
QStr2= "update " & tablename & " set d" & j & "_EmailRate=" & tot & " where svcid='" & svc1 & "' and channelid = 5;"
else if channel = 7 then
QStr2= "update " & tablename & " set d" & j & "_ChatRate=" & tot & " where svcid='" & svc1 & "' and channelid = 7;"
end if
end if
end if
' response.write QStr2
connectTTDB.Execute QStr2
end if
else
tot = 0
end if
ORAdbRowset.Close
else
QStr = "select sum(wkforwardedcnt) tot from hjobsummary where jobid=" & svc1 & " and (((RowDate = " & yesterday_rowdate & ") AND (StartTime = " & starttime & ")) OR ((RowDate = " & today_rowdate & ") AND (StartTime < " & starttime & ")) OR ((RowDate >= " & yesterday_rowdate & ") AND (RowDate < " & today_rowdate & ")))"
' response.write QStr
ORAdbRowset.Open QStr, connectORADB, 1, 3
if not (ORAdbRowset.EOF and ORAdbRowset.BOF) then
tot = ORAdbRowset("tot")
if tot > 0 then
QStr2= "update " & tablename & " set d" & j & "_JobRate=" & tot & " where svcid='" & svc1 & "' and channelid = 0;"
' response.write QStr2
connectTTDB.Execute QStr2
end if
else
tot = 0
end if
ORAdbRowset.Close
end if
TTdbRowset.MoveNext
wend
TTdbRowset.Close
next
end if
end if
' CHECK IF INTERVAL ROLL OVER HAS OCCURED
QStr= "select svcid, channelid, PreviousTotal, PreviousTimer, InitialTotal, InitialTimer, UTCIntervalStartTime from " & tablename & ";"
TTdbRowset.Open QStr, connectTTDB, 1, 3
if not TTdbRowset.EOF then
Prev_UTCIntervalStartTime = TTdbRowset("UTCIntervalStartTime")
TTdbRowset.close
QStr1= "select UTCIntervalStartTime from u.intervalinfo where intervalid = 'D1'"
TTdbRowset1.Open QStr1, connectTTDB, 1, 3
if not TTdbRowset1.EOF then
UTCIntervalStartTime = TTdbRowset1("UTCIntervalStartTime")
TTdbRowset1.close
if strcomp(UTCIntervalStartTime,Prev_UTCIntervalStart Time) <> 0 then
Session("TIMER") = 0
QStr= "update " & tablename & " set UTCIntervalStartTime=" & UTCIntervalStartTime & ";"
' response.write "<p>" & QStr & "</p>"
connectTTDB.Execute QStr
end if
end if
end if
' response.write "<p>DAILYCNT=" & Session("DAILYCNT") & ", TIMER=" & Session("TIMER") & ", UTCIntervalStartTime=" & UTCIntervalStartTime & ", Prev_UTCIntervalStartTime=" & Prev_UTCIntervalStartTime
' TRIGGER INTERVAL ROLL OVER HANDLING 5 MINUTES AFTER THE INTERVAL ROLLOVER HAS OCCURED IN OA
if Session("TIMER") = 300 then
newinterval = 1
end if
cur_sum_call = 0
cur_sum_email = 0
cur_sum_chat = 0
cur_sum_job = 0
rate_call = 0
rate_email = 0
rate_chat = 0
rate_job = 0
last_rate_call = 0
last_rate_email = 0
last_rate_chat = 0
last_rate_job = 0
QStr= "select svcid, channelid, PreviousTotal, PreviousTimer, InitialTotal, InitialTimer, UTCIntervalStartTime from " & tablename & ";"
TTdbRowset.Open QStr, connectTTDB, 1, 3
while not TTdbRowset.EOF
svc1 = TTdbRowset("svcid")
svc1 = rtrim(svc1)
PreviousTotal= TTdbRowset("PreviousTotal")
channel = TTdbRowset("channelid")
PreviousTimer= TTdbRowset("PreviousTimer")
InitialTotal= TTdbRowset("InitialTotal")
InitialTimer= TTdbRowset("InitialTimer")
Current_Timer = 0
Current_Total = 0
Tune_Rate = 0
Tune_Time = 0
Current_Time = 0
Current_Rate = 0
rts = 0
wkcnt = 0
abandcnt = 0
if channel <> 0 then
QStr1= "select svcclassid from u.svcclasssummary where svcclassid='" & svc1 & "';"
TTdbRowset1.Open QStr1, connectTTDB, 1, 3
if not TTdbRowset1.EOF then
rts = rts + 1
TTdbRowset1.Close
QStr2= "select sum(d1_wkarrivedcnt) s1, sum(d1_abandbehindcnt) a1, sum(d1_abandontargetcnt) a2, sum(d1_abandnogoalcnt) a3, sum(d1_abandaheadcnt) a4, sum(d1_abandcriticalcnt) a5 from u.svcclasssummary where svcclassid='" & svc1 & "';"
TTdbRowset1.Open QStr2, connectTTDB, 1, 3
wkcnt = TTdbRowset1("s1")
a1 = TTdbRowset1("a1")
a2 = TTdbRowset1("a2")
a3 = TTdbRowset1("a3")
a4 = TTdbRowset1("a4")
a5 = TTdbRowset1("a5")
abandcnt = a1 + a2 + a3 + a4 + a5
Current_Timer= timer
Current_Total= Current_Total + wkcnt
end if
TTdbRowset1.close
if odbc2 <> "" then
QStr1= "select svcclassid from u.svcclasssummary where svcclassid='" & svc1 & "';"
TTdbRowset2.Open QStr1, connectTTDB2, 1, 3
if not TTdbRowset2.EOF then
QStr2= "select sum(d1_wkarrivedcnt) s1, sum(d1_abandbehindcnt) a1, sum(d1_abandontargetcnt) a2, sum(d1_abandnogoalcnt) a3, sum(d1_abandaheadcnt) a4, sum(d1_abandcriticalcnt) a5 from u.svcclasssummary where svcclassid='" & svc1 & "';"
TTdbRowset2.Close
TTdbRowset2.Open QStr2, connectTTDB2, 1, 3
wkcnt = TTdbRowset2("s1")
a1 = TTdbRowset2("a1")
a2 = TTdbRowset2("a2")
a3 = TTdbRowset2("a3")
a4 = TTdbRowset2("a4")
a5 = TTdbRowset2("a5")
abandcnt = abandcnt + a1 + a2 + a3 + a4 + a5
if Current_Timer= 0 then
Current_Timer= timer
end if
' response.write svc1 & "wkcnt = " & wkcnt
rts = rts + 1
Current_Total = Current_Total + wkcnt
end if
TTdbRowset2.close
end if
else
QStr1= "select jobid from u.jobsummary where jobid=" & svc1 & ";"
TTdbRowset1.Open QStr1, connectTTDB, 1, 3
if not TTdbRowset1.EOF then
rts = rts + 1
QStr2= "select sum(d1_wkforwardedcnt) s1 from u.jobsummary where jobid=" & svc1 & ";"
TTdbRowset1.Close
TTdbRowset1.Open QStr2, connectTTDB, 1, 3
wkcnt = TTdbRowset1("s1")
Current_Timer= timer
Current_Total= Current_Total + wkcnt
end if
TTdbRowset1.close
if odbc2 <> "" then
QStr1= "select jobid from u.jobsummary where jobid=" & svc1 & ";"
TTdbRowset2.Open QStr1, connectTTDB2, 1, 3
if not TTdbRowset2.EOF then
QStr2= "select sum(d1_wkforwardedcnt) s1 from u.jobsummary where jobid=" & svc1 & ";"
TTdbRowset2.Close
TTdbRowset2.Open QStr2, connectTTDB2, 1, 3
wkcnt = TTdbRowset2("s1")
if Current_Timer= 0 then
Current_Timer= timer
end if
' response.write svc1 & "wkcnt = " & wkcnt
rts = rts + 1
Current_Total = Current_Total + wkcnt
end if
TTdbRowset2.close
end if
end if
if rts = 0 then
QStr= "update " & tablename & " set deleteind=2" & " where svcid = '" & svc1 & "' and channelid = " & channel & ";"
' response.write "<p>" & QStr & "</p>"
connectTTDB.Execute QStr
else
' response.write "<p>DAILYCNT=" & Session("DAILYCNT") & ", TIMER=" & Session("TIMER") & ", UTCIntervalStartTime=" & UTCIntervalStartTime & ", Prev_UTCIntervalStartTime=" & Prev_UTCIntervalStartTime
if newinterval = 1 then
InitialTotal = 0
InitialTimer = Current_Timer
PreviousTotal = Current_Total
InitialTimer = Current_Timer
QStr= "update " & tablename & " set InitialTimer=" & InitialTimer & ", InitialTotal=" & InitialTotal & " where svcid = '" & svc1 & "' and channelid = " & channel & ";"
' response.write "<p>" & QStr & "</p>"
connectTTDB.Execute QStr
tstarttime = Session("STARTTIME")
starthour = tstarttime / 100
if starthour < 10 then
starthour = "0" & starthour
end if
yesterday = dateadd("d", -1, date)
if month(date) < 10 then
rowmonth = "0" & month(date)
else
rowmonth = month(date)
end if
if day(date) < 10 then
rowday = "0" & day(date)
else
rowday = day(date)
end if
today_rowdate = year(date) & rowmonth & rowday & starthour
if month(yesterday) < 10 then
rowmonth = "0" & month(yesterday)
else
rowmonth = month(yesterday)
end if
if day(yesterday) < 10 then
rowday = "0" & day(yesterday)
else
rowday = day(yesterday)
end if
yesterday_rowdate = year(yesterday) & rowmonth & rowday & starthour
Session("YROWDATE") = yesterday_rowdate
Session("TROWDATE") = today_rowdate
' response.write "<p>rowdate is = " & rowdate & "</p>"
' response.write "<p>starttime is = " & starttime & "</p>"
' response.write " DAILYCNT=" & Session("DAILYCNT")
if Session("DAILYCNT") <> 0 then
JobDailyRate = 0
DailyRate = 0
&
|