progbar + sql connection
Hi - I am new to this site and ASP. I am learning 3.0 (my company has alot of stuff coded in the classic ASP).
I have seen this progbar code being used to show a progress bar on your site while you are waiting for an operation to complete the following code is what I am using:
<%Response.Buffer = True
server.scriptTimeout =25000
%>
<div id="ProgBar" style="font-family:Verdana; font-size=9pt;">Progress:<BR>
<TABLE style="color:red;" HEIGHT="16" Border=1>
<TR><TD BGCOLOR=RED ID="statuspic"></TD></TR></TABLE>
</div>
<script language="Javascript">var progBarWidth=250;
</script>
<%
iProcessedSoFar = 0
iTotalRecords = 300
ii = 0
strHTML="<Table width='80%'><TR><TD Width='100%' BGCOLOR='gray' align='CENTER'>Results:<TD><TR>"
for i = 0 to iTotalRecords
strHTML = strHTML & "<TR width='100%'><td width='100%' BGCOLOR='#FFCC66'>Your results</td></tr>"
'added delay loop
for ii = 0 to 40000
ii = ii +1
next
iProcessedSoFar = iProcessedSoFar + 1
pctComplete = (iProcessedSoFar / iTotalRecords)
If i mod 8 = 0 then
ShowProgress pctComplete
response.write pctComplete & "<BR>"
End if
Next
FinishProgress
strHTML=strHTML &"</TABLE>"
Response.write strHTML
Sub ShowProgress(nPctComplete)
response.write "here"
Response.Write "<SCR" & "IPT LANGUAGE='JavaScript'>" & vbCrlf
Response.Write "statuspic.width = Math.ceil(" & nPctComplete & " * 250);" &vbCrlf
Response.Write "</SCR" &"IPT>"
response.flush
End Sub
Sub FinishProgress
'Response.Write "<SCR" &"IPT LANGUAGE='JavaScript'>" & vbCrlf
'Response.Write "ProgBar.style.visibility ='hidden';" & vbCrLf
'Response.Write "</SCR" &"IPT>"
End sub
%>
I used this as my main page and I wanted to combine the following code:
<%
Dim strConnect
Response.Buffer = True
%>
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<HTML>
<HEAD>
<TITLE>ph0neman's music database</TITLE>
</HEAD>
<BODY>
<%
Dim intChosenRecord, strDirection, strOutputString, intCounter, intNoOfRecords
If Request.Form("ChosenRec") <> "" Then
intChosenRecord = Request.Form("ChosenRec")
strDirection = Request.Form("Dir")
Else
intChosenRecord = 1
strDirection = "Forward"
End If
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "top2000", strConnect, adOpenStatic, adLockReadOnly, adCmdTable
intNoOfRecords = objRS.RecordCount
objRS.Move intChosenRecord-1
strOutputString = "<TABLE BORDER=1>" & _
"<TR><TD WIDTH=""5%""><B>ID</B></TD>" & _
"<TD><B>Artist</B></TD>" & _
"<TD><B>Album</B></TD>" & _
"<TD><B>Track</B></TD>" & _
"<TD><B>Song Title</B></TD>" & _
"<TD><B>Year<B></TD></TR>"
If strDirection = "Forward" Then
While Not objRS.EOF
strOutputString = strOutputString & "<TR>" & _
"<TD> " & objRS("ID") & "</TD>" & _
"<TD>" & objRS("Artist") & "</TD>" & _
"<TD>" & objRS("Album") & "</TD>" & _
"<TD>" & objRS("Track") & "</TD>" & _
"<TD>" & objRS("Title") & "</TD>" & _
"<TD>" & objRS("Year") & "</TD>" & _
"</TR>"
objRS.MoveNext
Wend
objRS.MoveFirst
For intCounter = 1 To intChosenRecord-1
strOutputString = strOutputString & "<TR>" & _
"<TD> " & objRS("ID") & "</TD>" & _
"<TD>" & objRS("Artist") & "</TD>" & _
"<TD>" & objRS("Album") & "</TD>" & _
"<TD>" & objRS("Track") & "</TD>" & _
"<TD>" & objRS("Title") & "</TD>" & _
"<TD>" & objRS("Year") & "</TD>" & _
"</TR>"
objRS.MoveNext
Next
Else
While Not objRS.BOF
strOutputString = strOutputString & "<TR>" & _
"<TD> " & objRS("ID") & "</TD>" & _
"<TD>" & objRS("Artist") & "</TD>" & _
"<TD>" & objRS("Album") & "</TD>" & _
"<TD>" & objRS("Track") & "</TD>" & _
"<TD>" & objRS("Title") & "</TD>" & _
"<TD>" & objRS("Year") & "</TD>" & _
"</TR>"
objRS.MovePrevious
Wend
objRS.MoveLast
For intCounter = intNoOfRecords To intChosenRecord+1 Step -1
strOutputString = strOutputString & "<TR>" & _
"<TD> " & objRS("ID") & "</TD>" & _
"<TD>" & objRS("Artist") & "</TD>" & _
"<TD>" & objRS("Album") & "</TD>" & _
"<TD>" & objRS("Track") & "</TD>" & _
"<TD>" & objRS("Title") & "</TD>" & _
"<TD>" & objRS("Year") & "</TD>" & _
"</TR>"
objRS.MovePrevious
Next
End If
strOutputString = strOutputString & "</TABLE>"
objRS.Close
Set objRS = Nothing
Response.Write strOutputString
Response.Flush
%>
<BR>
<FORM ACTION="Moving.asp" METHOD="POST">
<H2>Format the list!</H2>
Where do you want this list to begin? Record
<SELECT SIZE=1 NAME="ChosenRec">
<%
For intCounter=1 To intNoOfRecords
Response.Write "<OPTION VALUE=" & intCounter & ">" & intCounter & "</OPTION>"
Next
%>
</SELECT><BR><BR>
Do you want the records to be listed
in <INPUT TYPE="RADIO" NAME="Dir" VALUE="Forward" CHECKED><B> forward</B></INPUT>
or <INPUT TYPE="RADIO" NAME="Dir" VALUE="Reverse"> <B>reverse</B></INPUT>
order (select one)?
<INPUT TYPE="SUBMIT" VALUE="View the list"></INPUT>
</FORM>
<A HREF="DisplaySource.asp?FileName=
<%= Server.URLEncode(Request.ServerVariables("PATH_INF O")) %> ">
Click here to see ASP source</A>
</BODY>
</HTML>
Forgive my ignorance. I am not really needing this to work only to try to understand the logic behind it. I originally tried to put my code (the 2nd one listed here), into the progbar code and I can get my results from my SQL query but I cant get the progress bar to show progress while I am waiting for the query.
Can anyone provide some insight into what I am doing wrong?
Here is what I am trying to run:
<%
Response.Buffer = True
server.scriptTimeout =25000
%>
<div id="ProgBar" style="font-family:Verdana; font-size=9pt;">Progress:
<TABLE style="color:red;" HEIGHT="16" Border=1><TR><TD BGCOLOR=RED ID=statuspic></TD></TR></TABLE><BR>
</div>
<script language="Javascript">var progBarWidth=250;</script>
<%
iProcessedSoFar = 0
iTotalSize = 2000 'Actual file size
ii = 0
for i = 0 to iTotalSize
'theDate = Date() + iProcessedSoFar
' next few lines are just a surrogate for whatever your processing function to be timed
'for ii = 0 to 2000
'ii = ii +1
'next
iProcessedSoFar = iProcessedSoFar + 1
pctComplete = (iProcessedSoFar / iTotalSize)
if i mod 8 = 0 then
ShowProgress pctComplete
'response.write pctComplete & "<BR>"
end if
next
FinishProgress
Sub ShowProgress(nPctComplete)
Response.Write "<SCR" & "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write "statuspic.width = Math.ceil(" & nPctComplete & " * 250);" & vbCrlf
Response.Write "</SCR" & "IPT>"
response.flush
End Sub
Sub FinishProgress
Response.Write "<SCR" & "IPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write "ProgBar.style.visibility ='hidden';" & vbCrLf
Response.Write "</SCR" & "IPT>"
end sub
%>
I have tried inserting the code into the the progbar script instead of using an include statement but still no luck.
Thanks
keep your kneeze in the breeze
__________________
keep your kneeze in the breeze
|