Home | Advertising Info6 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Saturday, April 20, 2024  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Info: looping with recordset A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
blauwvoet
Newbie
Newbie


Joined: April/05/2005
Online Status: Offline
Info: 1
Added: 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 info by blauwvoet
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Info: 28
Added: 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 info by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   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.

vbscript active server pages ASP vbscript SQL database informix oracle SQL Server Perl CGI Delphi PHP source code code sample samples program CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com