.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 27th, 2002, 10:03 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
error on ASP polling system. please help...

<i><b>Originally posted by : seni (s3ni@mailcity.com)</b></i><br /><br />I'm working on a ASP poll system. Making it as simple as possible. <br />The code are all done, however there seems to be run-time error. <br />its suppose to update the poll count on the database and show the percentage of the 3 options. <br />however after several submission, the percentage and graph goes back to 0 and never increase again...no matter how matter vote i made. <br />If possible, please help me take a look at the code and tell me what's wrong with it. <br />Thanks a million. <br /><br /><br /><html><br /><head><title>poll.asp</title><br /></head><br /><body><br /><% <br /><br />'OPENING THE CONNECTION WITH DATABASE VIA DSN-LESS CONNCTION<br /><br />set OCONN = Server.CreateObject("ADODB.Connection")<br />DBPATH = Server.MapPath("POLL1.mdb")<br />SETCONNECTION = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPATH & ";Persist Security Info="FALSE""<br />OCONN.Open(SETCONNECTION)<br /><br />'QUERY TO SELECT THE DATA FROM THE TABLE<br />strSQL = "select * from POLL1"<br />set ORS = OCONN.Execute(strSQL)<br /><br /><br />'WE DECLARE AN ARRAY OF LENGTH = 3 i.e. 0,1,2 <br />dim OPTIONVALUE(2)<br />OPTIONVALUE(0) = ORS.Fields(0)<br />OPTIONVALUE(1) = ORS.Fields(1)<br />OPTIONVALUE(2) = ORS.Fields(2)<br /><br /><br />'CHECK TO SEE WHICH OPTION WAS CLICKED BY USER AND THEN INCREMENT THAT OPTION'S<br />'VALUE BY ONE<br />CHECKER = Request.Form ("mysite_poll")<br />if CHECKER = "OPTION1" then<br />OPTIONVALUE_INSERT = OPTIONVALUE(0) +1<br />strINSERT = "UPDATE POLL1 SET OPTION1 = " & OPTIONVALUE_INSERT<br />OCONN.Execute(strINSERT)<br />elseif CHECKER = "OPTION2" then<br />OPTIONVALUE_INSERT = OPTIONVALUE(1) +1<br />strINSERT = "UPDATE POLL1 SET OPTION2 = " & OPTIONVALUE_INSERT<br />OCONN.Execute(strINSERT)<br />elseif CHECKER = "OPTION3" then<br />OPTIONVALUE_INSERT = OPTIONVALUE(2) +1<br />strINSERT = "UPDATE POLL1 SET OPTION3 = " & OPTIONVALUE_INSERT<br />OCONN.Execute(strINSERT)<br />end if<br /><br />'REQUERY THE RECORDS AND FILL THEM IN SAME ARRAY TO REPLACE OLD VALUES<br />'SO THAT WE HAVE LATEST VALUES TO SHOW<br />ORS.Requery<br />OPTIONVALUE(0) = ORS.Fields(0)<br />OPTIONVALUE(1) = ORS.Fields(1)<br />OPTIONVALUE(2) = ORS.Fields(2)<br /><br />'TAKING THE SUM OF VOTES, DIVIDE AN OPTION WITH SUM<br />'TO GET A PERCENTAGE AND THE MULTIPLY WITH 100 <br />TOTAL_OF_OPTIONS = OPTIONVALUE(0)+OPTIONVALUE(1)+OPTIONVALUE(2)<br />dim PERCENT_OPTION_VALUE(2)<br />PERCENT_OPTION_VALUE(0) = (OPTIONVALUE(0)/TOTAL_OF_OPTIONS) * 100<br />PERCENT_OPTION_VALUE(1) = (OPTIONVALUE(1)/TOTAL_OF_OPTIONS) * 100<br />PERCENT_OPTION_VALUE(2) = (OPTIONVALUE(2)/TOTAL_OF_OPTIONS) * 100<br /><br />'USING THE RESPONSE METHOD TO WRITE THE RESULTS TO THE USER IN A<br />'TABULAR FORMAT<br />Response.write "<table border=0 cellpadding='0' cellspacing='0'>"<br />Response.write "<tr>"<br />Response.write "<td width=150>You'll Live:</td>"<br />Response.write "<td width=310><IMG SRC='blue.gif' width=" & PERCENT_OPTION_VALUE(0)*3 & " height=15 ALT='blue' BORDER=0></td>"<br />Response.write "<td>" & FormatNumber(PERCENT_OPTION_VALUE(0),0) & "%</td>"<br />Response.write "</tr>"<br />Response.write "<tr>"<br />Response.write "<td width=150>You'r Okay:</td>"<br />Response.write "<td width=310><IMG SRC='blue.gif' width=" & PERCENT_OPTION_VALUE(1)*3 & " height=15 ALT='blue' BORDER=0></td>"<br />Response.write "<td>" & FormatNumber(PERCENT_OPTION_VALUE(1),0) & "%</td>"<br />Response.write "</tr>"<br />Response.write "<tr>"<br />Response.write "<td width=150>You'r Happy With It:</td>"<br />Response.write "<td width=310><IMG SRC='blue.gif' width=" & PERCENT_OPTION_VALUE(2)*3 & " height=15 ALT='blue' BORDER=0></td>"<br />Response.write "<td>" & FormatNumber(PERCENT_OPTION_VALUE(2),0) & "%</td>"<br />Response.write "</tr>"<br />Response.write "</table>"<br />Response.write "<i>Your Selection : </i>" & Request.Form ("mysite_poll")<br /><br />'CLOSE THE RECORDSET<br />ORS.Close<br />Set ORS = Nothing<br />'CLOSE THE CONNCECTION<br />OCONN.Close<br />Set OCONN = Nothing<br />%><br /></body><br /></html><br /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > error on ASP polling system. please help...


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 3 hosted by Hostway