Can someone look at this and tell me what I'm missing. It's been a while since I've worked in ASP. Eventually, I want to loop through and add up my averages, but I'm getting stuck here.
I'm getting the following error
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
<%
Set oConn = Server.CreateObject("ADODB.Connection"
sConn = "uid=h355;pwd=ga1446;dsn=tracking"
oConn.ConnectionTimeout=720
oConn.CommandTimeout=180
oConn.Open sConn
dim oRs
set oRs = Server.CreateObject("ADODB.Recordset"
oRs.Open
'oRs.ActiveConnection = oConn
s_date = "10/1/02"
e_date = "10/7/02"
txtarea = "13W"
x = dateDiff("d",cdate(s_date),cdate(e_date))
'response.write x
for i = 0 to x
nextday = dateAdd("d",i,cdate(s_date))
'response.write nextday & "<br>"
sqlQry1="Select site, schools.area, schcat, schoolname, avg(total_enrollment) as enrollment "
sqlQry1 = sqlQry1 & "from (enrollment inner join tbl_scanned_sales on "
sqlQry1 = sqlQry1 & "enrollment.cus_site = tbl_scanned_sales.sc_site) inner join schools "
sqlQry1 = sqlQry1 & "on tbl_scanned_sales.sc_site = schools.site where "
sqlQry1 = sqlQry1 & "sc_sales_date ='" & nextday & "'"
sqlQry1 = sqlQry1 & " and schools.area='" & txtArea & "
sqlQry1 = sqlQry1 & " group by schcat, schools.area, sc_site, schoolname order by schoolname;"
response.write sqlQry1 & "<br><br>"
response.write oRs("enrollment"
next
set oConn = nothing
set ors=nothing
%>
I'm getting the following error
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
<%
Set oConn = Server.CreateObject("ADODB.Connection"
sConn = "uid=h355;pwd=ga1446;dsn=tracking"
oConn.ConnectionTimeout=720
oConn.CommandTimeout=180
oConn.Open sConn
dim oRs
set oRs = Server.CreateObject("ADODB.Recordset"
oRs.Open
'oRs.ActiveConnection = oConn
s_date = "10/1/02"
e_date = "10/7/02"
txtarea = "13W"
x = dateDiff("d",cdate(s_date),cdate(e_date))
'response.write x
for i = 0 to x
nextday = dateAdd("d",i,cdate(s_date))
'response.write nextday & "<br>"
sqlQry1="Select site, schools.area, schcat, schoolname, avg(total_enrollment) as enrollment "
sqlQry1 = sqlQry1 & "from (enrollment inner join tbl_scanned_sales on "
sqlQry1 = sqlQry1 & "enrollment.cus_site = tbl_scanned_sales.sc_site) inner join schools "
sqlQry1 = sqlQry1 & "on tbl_scanned_sales.sc_site = schools.site where "
sqlQry1 = sqlQry1 & "sc_sales_date ='" & nextday & "'"
sqlQry1 = sqlQry1 & " and schools.area='" & txtArea & "
sqlQry1 = sqlQry1 & " group by schcat, schools.area, sc_site, schoolname order by schoolname;"
response.write sqlQry1 & "<br><br>"
response.write oRs("enrollment"
next
set oConn = nothing
set ors=nothing
%>