Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2005, 12:37 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

%>


 
Old April 11th, 2005, 11:40 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

in your FOR NEXT LOOP you just keep opening your recordset...
 
Old April 12th, 2005, 06:03 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks I have just edited the last bit, which was:
<%
.
.
    adday = adday + 7

NEXT
    RawCountRS.Close
    set RawCountRS=Nothing

%>

to that:
<%
.
.
    adday = adday + 7

    RawCountRS.Close

NEXT

    set RawCountRS=Nothing

%>







Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I send raw data directly to a serial port peterasimpson VB.NET 0 January 27th, 2008 09:42 PM
raw ftp command zhebincong BOOK: Beginning Unix ISBN: 0-7645-7994-0 1 May 18th, 2006 09:18 AM
Problems returning count in Stored Procedure planza SQL Language 1 December 21st, 2005 03:24 PM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
How to display Oracle raw(10) in Access 97 lgharis Access 0 February 27th, 2004 12:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.