Raw count problems
Hi there
I have the following code that I am using to check the maximum number of requests in my database, to return a feedback for the user. But unfortunately I get an error message as shown here:
Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/work/project/sortedms/user/data.asp, line 89
And the line indicated is:
RawCountRS.open strRawCount,objConnection,3,3
And my code is as following
data.asp
<%
Dim formavail_from_month, formavail_from_day, formavail_from_year, formDay, formavail_from_hour, formavail_from_min, formavail_until_hour, formavail_until_min
'define the parameters which comming from the form
formavail_from_month = Request.Form("avail_from_month")
formavail_from_day = Request.Form("avail_from_day")
formavail_from_year = Request.Form("avail_from_year")
formDay = Request.Form("Day")
formavail_from_hour = Request.Form("avail_from_hour")
formavail_from_min = Request.Form("avail_from_min")
formavail_until_hour = Request.Form("avail_until_hour")
formavail_until_min = Request.Form("avail_until_min")
dim strDataPath, strConnectString, objConnection, strRawCount, RawCountRS
'set connection strings for entire application
strDataPath = server.MapPath("results.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
+ " Data Source= " & strDataPath & ";"_
+ " Mode=Share Deny None;User Id=admin;PASSWORD=;"
if not IsObject("ojbConnection") then
set objConnection=Server.CreateObject("ADODB.Connectio n")
objConnection.ConnectionTimeout = 15
objConnection.CommandTimeout = 10
objConnection.Mode = 3 'adModeReadWrite
if objConnection.state = 0 then
objConnection.Open strConnectString
end if
end if
if not isObject("RawCountRS") then
set RawCountRS=Server.CreateObject("ADODB.RecordSet")
end if
if RawCountRS.state <> 0 then
RawCountRS.close
end if
dim formDate, totalRaws
formDate = "" & formavail_from_month & "/" & formavail_from_day & "/" & formavail_from_year & ""
dim StartDate, EndDate, p, totweek, adday, dateFormed, formDayValue
StartDate = 1/1/2005
EndDate = 5/28/2005
totweek = DateDiff("w", startDate, DateAdd("d", 7, EndDate), vbSaturday)
if formDay = "Saturday" then
formDayValue = 0
end if
if formDay = "Sunday" then
formDayValue = 1
end if
if formDay = "Monday" then
formDayValue = 2
end if
if formDay = "Tuesday" then
formDayValue = 3
end if
if formDay = "Wednesday" then
formDayValue = 4
end if
if formDay = "Thursday" then
formDayValue = 5
end if
if formDay = "Friday" then
formDayValue = 6
end if
adday = formDayValue
Response.Write(StartDate & "<BR>" & VBCRLF )
Response.Write(EndDate & "<BR>" & VBCRLF )
Response.Write("<TABLE BORDER=""1"">" & VBCRLF )
Response.Write("<TR>" & VBCRLF )
Response.Write("<TH scope='col' bgcolor=#CCCC99>Week Number</TH>" & VBCRLF )
Response.Write("<TH scope='col' bgcolor=#CCCC99 WIDTH=""100"">Date</TH>" & VBCRLF )
Response.Write("<TH scope='col' bgcolor=#CCCC99 WIDTH=""100"">Day</TH>" & VBCRLF )
Response.Write("<TH scope='col' bgcolor=#CCCC99 WIDTH=""100"">Time</TH>" & VBCRLF )
Response.Write("<TH scope='col' bgcolor=#CCCC99 WIDTH=""100"">Status</TH>" & VBCRLF )
Response.Write("</TR>" & VBCRLF )
FOR p=1 to totweek
dateFormed = DateAdd("d", adday, startDate)
strRawCount = "SELECT count(*) as raws FROM data WHERE Date = #" & dateFormed & "# and avail_from_hour = '" & formavail_from_hour & "' and RequestorCategory = 'Faculty'"
RawCountRS.open strRawCount,objConnection,3,3
totalRaws = RawCountRS("raws")
if totalRaws > 9 or totalRaws = 9 Then
Response.Write(" <tr>" & VBCRLF )
Response.Write(" <TD bgcolor=#EEEECC>" & p & ".</td>" & VBCRLF )
Response.Write(" <TD bgcolor=#EEEECC>" & DatePart("d",dateFormed) & "/" & MonthName(DatePart("m",dateFormed)) & "/" & DatePart("yyyy",dateFormed) & "</td>" & VBCRLF )
Response.Write(" <TD bgcolor=#EEEECC>" & formDay & "</td>" & VBCRLF )
Response.Write(" <TD bgcolor=#EEEECC>" & formavail_from_hour & ":" & formavail_from_min & " - " & formavail_until_hour & ":" & formavail_until_min & "</td>" & VBCRLF )
Response.Write(" <TD bgcolor=#EEEECC><B>Fail</B></td>" & VBCRLF )
Response.Write(" </tr>" & VBCRLF )
End if
adday = adday + 7
NEXT
RawCountRS.Close
set RawCountRS=Nothing
%>
|