Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 6th, 2003, 05:25 PM
0kc0mputer 0kc0mputer is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 0kc0mputer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Database Looping and Error "80020009"

Okay, here's my problem. I must loop through a recordset until I get through all the records, but I need to run a second loop that tests for groups of time periods. Here's the code:

intTimeTot = 0
do while not rs.eof
dtmCheckTime = rs("time_start")
intChoices = 0
do while dtmCheckTime = rs("time_start")
intChoices = intChoices + 1
rs.movenext
loop
intTimeTot = intTimeTot + 1

{other code}...

loop

I get the error "error '80020009' Exception occurred." at the "do while dtmCheckTime = rs("time_start")" line, and it happens when it gets to the end of the recordset.

Basically, I need that section of code to count as many recordsets at that point that have the same time period. If there is a better way to do it, please let me know.

Thanks in advance

Last edited by 0kc0mputer : June 6th, 2003 at 05:28 PM.

Reply With Quote
  #2  
Old June 6th, 2003, 11:43 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
You should do all that kinda of stuff in the DB. There's no need to spent time writing more code when SQL can do it all for you! :P

SELECT COUNT(time_start) FROM table GROUP BY time_start
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old June 7th, 2003, 02:02 PM
0kc0mputer 0kc0mputer is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 0kc0mputer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That would be great, but there might be times that will reoccur, but on different days. There is a DB field called 'dat' that holds the date of the event. I'm still a little bit new on SQL. Can an aggregate be structured so it would group the times by their dates, and return the same count?

Reply With Quote
  #4  
Old June 7th, 2003, 08:31 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Note I assume you're using SQLServer.

You can aggregate by any part of the datetime field. Using:

SELECT 108, CONVERT(VARCHAR,datetimefieldname,108)

Will return only the time section.

This article will help you out in any future issues.

Reply With Quote
  #5  
Old June 8th, 2003, 03:17 PM
0kc0mputer 0kc0mputer is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 7 0kc0mputer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks! That's a good article.

Reply With Quote
  #6  
Old May 22nd, 2007, 12:25 PM
rshaff23 rshaff23 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 2 rshaff23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 11 sec
Reputation Power: 0
Similar Problem...

I have a similar problem, except I am trying to build a table that lists the different down times of different applications according to 1 of 4 different codes. When an application has no listing for such a procedure, it should put up a blank space in the cell where the info should have been. Whenever this runs, I hit an error on the first point in which data is not found in the field for that recordset. I tried to correct it by writing "if then" statements, but it is not working to place a blank space in if the field is null. instead, it puts the error code and message in that cell in the table. Any help would be appreciated. Here is the code:




if obj1rs.eof then
'Do nothing, end the table
response.write("<tr><td> There are no Application Objectives associated with this application</td></tr>")
else
'Add the records
response.write("</td></tr>")
response.write("<tr><td><table border='2' style='border-collapse: collapse' width='100%'>")
response.write("<tr BGCOLOR='ffffe0'><td align='center'><b>RTO</b></td>")
response.write("<td align='center'><b>RPO</b></td><td align='center'><b>SRTO</b></td><td align='center'><b>SRPO</b></td></tr>")

do until obj1rs.eof
response.write ("<tr><td align='center'>")
if obj1rs("goal_hrs")="" then
response.write ("&nbsp;</td>")
else
response.write (obj1rs("goal_hrs") & "</td>")
end if

response.write("<td align='center'>")
if obj2rs("goal_hrs")="" then
response.write ("&nbsp;</td>")
else
response.write (obj2rs("goal_hrs") & "</td>")
end if

response.write("<td align='center'>")
if obj3rs("goal_hrs")="" then
response.write ("&nbsp;</td>")
else
response.write (obj3rs("goal_hrs") & "</td>")
end if

response.write("<td align='center'>")
if obj4rs("goal_hrs")="" then
response.write ("&nbsp;</td>")
else
response.write (obj4rs("goal_hrs") & "</td></tr>")
end if
obj1rs.movenext
loop
end if

response.write("</table></td></tr>")

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > Database Looping and Error "80020009"


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway