Jay.B
08-17-2004, 09:43 AM
I have a page that contains two table each populated by a stored procedure. when i run the page I keep getting a runtime error '800a01a8' which is object required. What is confusing me is that the obj is clearly set (in code anyway) What is causing this.
Here is my code:
///////////////////////////////////////////
<%@ Language=VBScript%>
<% Option Explicit %>
<!--#include file="adovbs.inc" -->
<!--#include file="connect.asp" -->
<% Response.Buffer = True
'Response.ContentType="application/vnd.ms-excel"
Response.ExpiresAbsolute = Now() -2
Response.AddHeader "Cache-Control", "private"
dim oRS
dim oCmd
dim typerept
typerept = "BURhdcnt.asp?bureau"
dim title
title = "Headcount Report"
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
oCmd.CommandText = "sp_headcount"
oCmd.CommandType = 4 ' adCmdStoredProc
Set oRs = Server.CreateObject("ADODB.RecordSet")
oRs.CursorType = adOpenForwardOnly
oRs.Open oCmd, , adOpenforwardonly,adLockReadOnly
call write_html(title,typerept)
%>
<html>
<head>
<TITLE> Current Employment Statistics of Employees in Treasury</TITLE>
<Link rel="stylesheet" type="text/css" href="webstyle.css">
</head><BODY >
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
Sub Write_HTML(title,typerept)
Dim r, count'r is an index variable for the for loops, count is the number of rows of data
dim i
dim rowtotal(50)
Dim arrTotals(50)
count = oRS.Fields.Count - 1
' r = "0"
for r = 0 to count
arrTotals(r) = "0"
next
oRS.MoveFirst
'recordsets start at zero
'first generate the start of the table
response.write "<table bordercolorlight=#666666 bordercolordark=#333333 border=2 CELLSPACING=0 CELLPADDING=2 WIDTH=100% HEIGHT=30% >"
response.write "<CAPTION ALIGN=top>" & "Department of the Treasury" & "<br>" & title & "</CAPTION>"
Response.Write("<THEAD bgcolor=#cccccc>" & vbCrLf)
for r = 1 to count 'populate the header
Response.Write("<TH width=5% scope='col'><font size=-1>" & oRS(r).Name & " </TH>" & vbCrLf)
next
Response.Write("</THEAD>" & vbCrLf)
'Now populate the table
Do Until oRS.EOF
Response.Write("<tr>" & vbCrLf)
Response.Write("<td scope='row'><font size=-1><a href='" & typerept & "=" & oRS(0) & "'>" & oRS(1) & "</td>" & vbCrLf)
for r = 2 to count
if isnull(oRS(r)) then
response.write("<td align=right><font size=-1>" & 0 & "</td>" & vbcrlf)
else
Response.Write("<td align=right><font size=-1>" & oRS(r) & "</td>" & vbCrLf)
end if
Next
Response.Write("</tr>" & vbCrLf)
oRS.MoveNext
Loop
oRS=oRS.nextRecordset
Response.Write("<tr>" & vbCrLf)
Response.Write("<td span=2><font size=-1><b>Grand Total</td>")
for r = 0 to 9
Response.Write("<td align=right><font size=-1><b>" & oRS(r) & "</td>" & vbCrLf)
next
Response.Write("</tr></b>" & vbCrLf)
response.write("<tr> </tr>")
Response.Write("</table>")
set oRS = nothing
End Sub
</script><noscript></noscript>
''/////////////////////////////////////////////////////////////////////
<%
dim oCmd1
dim oCC
Set oCmd1= Server.CreateObject("ADODB.Command")
Set oCmd1 = Server.CreateObject("ADODB.Command")
oCmd1.CommandText = "sp_headcountburocc"
oCmd1.CommandType = 4 ' adCmdStoredProc
Set oCC = Server.CreateObject("ADODB.RecordSet")
oCC.CursorType = adOpenForwardOnly
oCC.ActiveConnection = oCC
''oCC.Open oCmd1, , adOpenforwardonly,adLockReadOnly
%>
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
Dim r, count'r is an index variable for the for loops, count is the number of rows of data
dim i
dim rowtotal(50)
Dim arrTotals(50)
count = oCC.Fields.Count - 1 'this is the line throwing the error
' r = "0"
for r = 0 to count
arrTotals(r) = "0"
next
oCC.MoveFirst
'recordsets start at zero
'first generate the start of the table
response.write "<table bordercolorlight=#666666 bordercolordark=#333333 border=2 CELLSPACING=0 CELLPADDING=2 WIDTH=100% HEIGHT=30% >"
response.write "<CAPTION ALIGN=top>" & "Department of the Treasury" & "<br>" & title & "</CAPTION>"
Response.Write("<THEAD bgcolor=#cccccc>" & vbCrLf)
for r = 1 to count 'populate the header
Response.Write("<TH width=5% scope='col'><font size=-1>" & oCC(r).Name & " </TH>" & vbCrLf)
next
Response.Write("</THEAD>" & vbCrLf)
'Now populate the table
Do Until oCC.EOF
Response.Write("<tr>" & vbCrLf)
Response.Write("<td scope='row'><font size=-1><a href='" & typerept & "=" & oCC(0) & "'>" & oCC(1) & "</td>" & vbCrLf)
for r = 2 to count
if isnull(oCC(r)) then
response.write("<td align=right><font size=-1>" & 0 & "</td>" & vbcrlf)
else
Response.Write("<td align=right><font size=-1>" & oCC(r) & "</td>" & vbCrLf)
end if
Next
Response.Write("</tr>" & vbCrLf)
oCC.MoveNext
Loop
oCC=oCC.nextRecordset
Response.Write("<tr>" & vbCrLf)
Response.Write("<td span=2><font size=-1><b>Grand Total</td>")
for r = 0 to 9
Response.Write("<td align=right><font size=-1><b>" & oCC(r) & "</td>" & vbCrLf)
next
Response.Write("</tr></b>" & vbCrLf)
response.write("<tr> </tr>")
Response.Write("</table>")
set oCC = nothing
End Sub
</script><noscript></noscript>
<a href="descriptions/headcountexp.html"><IMG SRC="images/question1.GIF" alt="Report Description" WIDTH=16 HEIGHT=16 BORDER=0></a>
<!--#include file=listpayperiod.asp-->
<p> <IMG SRC="/images/final_hrconnect_logo.gif" alt=" hrconnect logo" BORDER=0></p>
</body>
</html>
Here is my code:
///////////////////////////////////////////
<%@ Language=VBScript%>
<% Option Explicit %>
<!--#include file="adovbs.inc" -->
<!--#include file="connect.asp" -->
<% Response.Buffer = True
'Response.ContentType="application/vnd.ms-excel"
Response.ExpiresAbsolute = Now() -2
Response.AddHeader "Cache-Control", "private"
dim oRS
dim oCmd
dim typerept
typerept = "BURhdcnt.asp?bureau"
dim title
title = "Headcount Report"
Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = oConn
oCmd.CommandText = "sp_headcount"
oCmd.CommandType = 4 ' adCmdStoredProc
Set oRs = Server.CreateObject("ADODB.RecordSet")
oRs.CursorType = adOpenForwardOnly
oRs.Open oCmd, , adOpenforwardonly,adLockReadOnly
call write_html(title,typerept)
%>
<html>
<head>
<TITLE> Current Employment Statistics of Employees in Treasury</TITLE>
<Link rel="stylesheet" type="text/css" href="webstyle.css">
</head><BODY >
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
Sub Write_HTML(title,typerept)
Dim r, count'r is an index variable for the for loops, count is the number of rows of data
dim i
dim rowtotal(50)
Dim arrTotals(50)
count = oRS.Fields.Count - 1
' r = "0"
for r = 0 to count
arrTotals(r) = "0"
next
oRS.MoveFirst
'recordsets start at zero
'first generate the start of the table
response.write "<table bordercolorlight=#666666 bordercolordark=#333333 border=2 CELLSPACING=0 CELLPADDING=2 WIDTH=100% HEIGHT=30% >"
response.write "<CAPTION ALIGN=top>" & "Department of the Treasury" & "<br>" & title & "</CAPTION>"
Response.Write("<THEAD bgcolor=#cccccc>" & vbCrLf)
for r = 1 to count 'populate the header
Response.Write("<TH width=5% scope='col'><font size=-1>" & oRS(r).Name & " </TH>" & vbCrLf)
next
Response.Write("</THEAD>" & vbCrLf)
'Now populate the table
Do Until oRS.EOF
Response.Write("<tr>" & vbCrLf)
Response.Write("<td scope='row'><font size=-1><a href='" & typerept & "=" & oRS(0) & "'>" & oRS(1) & "</td>" & vbCrLf)
for r = 2 to count
if isnull(oRS(r)) then
response.write("<td align=right><font size=-1>" & 0 & "</td>" & vbcrlf)
else
Response.Write("<td align=right><font size=-1>" & oRS(r) & "</td>" & vbCrLf)
end if
Next
Response.Write("</tr>" & vbCrLf)
oRS.MoveNext
Loop
oRS=oRS.nextRecordset
Response.Write("<tr>" & vbCrLf)
Response.Write("<td span=2><font size=-1><b>Grand Total</td>")
for r = 0 to 9
Response.Write("<td align=right><font size=-1><b>" & oRS(r) & "</td>" & vbCrLf)
next
Response.Write("</tr></b>" & vbCrLf)
response.write("<tr> </tr>")
Response.Write("</table>")
set oRS = nothing
End Sub
</script><noscript></noscript>
''/////////////////////////////////////////////////////////////////////
<%
dim oCmd1
dim oCC
Set oCmd1= Server.CreateObject("ADODB.Command")
Set oCmd1 = Server.CreateObject("ADODB.Command")
oCmd1.CommandText = "sp_headcountburocc"
oCmd1.CommandType = 4 ' adCmdStoredProc
Set oCC = Server.CreateObject("ADODB.RecordSet")
oCC.CursorType = adOpenForwardOnly
oCC.ActiveConnection = oCC
''oCC.Open oCmd1, , adOpenforwardonly,adLockReadOnly
%>
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
Dim r, count'r is an index variable for the for loops, count is the number of rows of data
dim i
dim rowtotal(50)
Dim arrTotals(50)
count = oCC.Fields.Count - 1 'this is the line throwing the error
' r = "0"
for r = 0 to count
arrTotals(r) = "0"
next
oCC.MoveFirst
'recordsets start at zero
'first generate the start of the table
response.write "<table bordercolorlight=#666666 bordercolordark=#333333 border=2 CELLSPACING=0 CELLPADDING=2 WIDTH=100% HEIGHT=30% >"
response.write "<CAPTION ALIGN=top>" & "Department of the Treasury" & "<br>" & title & "</CAPTION>"
Response.Write("<THEAD bgcolor=#cccccc>" & vbCrLf)
for r = 1 to count 'populate the header
Response.Write("<TH width=5% scope='col'><font size=-1>" & oCC(r).Name & " </TH>" & vbCrLf)
next
Response.Write("</THEAD>" & vbCrLf)
'Now populate the table
Do Until oCC.EOF
Response.Write("<tr>" & vbCrLf)
Response.Write("<td scope='row'><font size=-1><a href='" & typerept & "=" & oCC(0) & "'>" & oCC(1) & "</td>" & vbCrLf)
for r = 2 to count
if isnull(oCC(r)) then
response.write("<td align=right><font size=-1>" & 0 & "</td>" & vbcrlf)
else
Response.Write("<td align=right><font size=-1>" & oCC(r) & "</td>" & vbCrLf)
end if
Next
Response.Write("</tr>" & vbCrLf)
oCC.MoveNext
Loop
oCC=oCC.nextRecordset
Response.Write("<tr>" & vbCrLf)
Response.Write("<td span=2><font size=-1><b>Grand Total</td>")
for r = 0 to 9
Response.Write("<td align=right><font size=-1><b>" & oCC(r) & "</td>" & vbCrLf)
next
Response.Write("</tr></b>" & vbCrLf)
response.write("<tr> </tr>")
Response.Write("</table>")
set oCC = nothing
End Sub
</script><noscript></noscript>
<a href="descriptions/headcountexp.html"><IMG SRC="images/question1.GIF" alt="Report Description" WIDTH=16 HEIGHT=16 BORDER=0></a>
<!--#include file=listpayperiod.asp-->
<p> <IMG SRC="/images/final_hrconnect_logo.gif" alt=" hrconnect logo" BORDER=0></p>
</body>
</html>