Home | Advertising Info2 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Sunday, May 12, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Topic: looping with recordset Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
blauwvoet
Newbie
Newbie


Joined: April/05/2005
Online Status: Offline
Posts: 1
Posted: April/05/2005 at 6:15pm | IP Logged Quote blauwvoet

Hey, i want to do the following: I want to publish a number of right answers from an access database.
The database has question1, question2, question3, ... as fieldname. Because there are 80 questions and the answers are always yes or no, I want to use a loop. But I don't know how i can manage this. I gues for i=1 has something to dow ith it but i don't seem to manage it the right way.

This is the code i use:

Dim rsTotaalQuestion1
Dim strTotaalQuestion1
Set rsTotaalQuestion1 = Server.CreateObject("ADODB.Recordset")
strTotaalQuestion1 = "SELECT COUNT(*) AS TotalQuestion1 FROM poll WHERE question1 = 'Yes' "
rsTotaalQuestion1.Open strTotaalQuestion1, AdoCon
strTotaalQuestion1 = (rsTotaalQuestion1("TotaalQuestion1"))
rsTotaalQuestion1.close
Set rsTotaalQuestion1 = Nothing

Dim rsTotaalQuestion2
Dim strTotaalQuestion2
Set rsTotaalQuestion2 = Server.CreateObject("ADODB.Recordset")
strTotaalQuestion2 = "SELECT COUNT(*) AS TotalQuestion2 FROM poll WHERE question2 = 'Yes' "
rsTotaalQuestion2.Open strTotaalQuestion2, AdoCon
strTotaalQuestion2 = (rsTotaalQuestion2("TotaalQuestion2"))
rsTotaalQuestion2.close
Set rsTotaalQuestion2 = Nothing .....

Anyone an idea???

Back to Top View blauwvoet's Profile Search for other posts by blauwvoet
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Posts: 28
Posted: May/27/2006 at 9:52am | IP Logged Quote firas_TheGeek

this code will do the job

Dim rsTotaalQuestion1
Dim arrTotaalQuestion(80)
Set rsTotaalQuestion1 = Server.CreateObject("ADODB.Recordset")

for i=1 to 80

strTotaalQuestion1 = "SELECT COUNT(*) AS TotalQuestion1 FROM poll WHERE question" & i & " = 'Yes' "
rsTotaalQuestion1.Open strTotaalQuestion1, AdoCon
arrTotaalQuestion(i+1)= (rsTotaalQuestion1("TotaalQuestion" & i))
rsTotaalQuestion1.close

next


Set rsTotaalQuestion1 = Nothing

 

then to view all the results

for i =1 to 80

response.write arrTotaalQuestion(i) & "<br>"

next

 

 

Hope this heps

 

 

Best Regards



__________________
Firas S Assaad (TheGeek)
firas489@gmail.com
0096892166434
http://firas-thegeek.blogspot.com
Back to Top View firas_TheGeek's Profile Search for other posts by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP control controls class classes module script Scripts applet CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com