?
Solved

Error Overflow

Posted on 2008-10-27
5
Medium Priority
?
726 Views
Last Modified: 2012-05-05
Hi, I am getting an overflow error on my code - ASP - line 164,
 Can somebody tell me what can be wrong ?

<% level="../"%>
<!--#include file="compHandi.asp"-->
<!--#include file="logincheck.asp"-->
<!--#include file="../include/intialize.inc"-->
<!--include file="../include/connection.asp"-->
<!--#include file="../../Connections/sqlConn1.asp" -->
 
<%
dim trigger
trigger = 1
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * from Scores WHERE SSN = '" & session("username") & "'"
rs.Open sql,conSQL,3,3
if rs.recordcount = 0 then trigger = 2
					'---------------------------------------
if trigger <> 2 then
		dim eagleCount, birdieCount, parCount, bogeyCount, doubleCount, otherCount, totalCount
		'right here...............dim avg18, low18, high18
		eagleCount = 0
		birdieCount = 0
		parCount = 0
		bogeyCount = 0
		doubleCount = 0
		otherCount = 0
		totalCount = 0
		
		rs.movefirst
		while not rs.eof
			call breakdown
			rs.movenext
		wend
	
	
		dim numRecords18
		dim numRecords9
		dim average18
		dim average9
		dim lowRound18
		dim lowRound9
		dim highRound18
		dim highRound9
		
	call findCount("Full", "Full", numRecords18)
	call findAverage("Full", "Full", numRecords18, average18)
	call findLowest("Full", "Full", lowRound18)
	call findHighest("Full", "Full", highRound18)
	call findCount("Front", "Back", numRecords9)
	call findAverage("Front", "Back", numRecords9, average9)
	call findLowest("Front", "Back", lowRound9)
	call findHighest("Front", "Back", highRound9)
	
		dim average3
		dim average4
		dim average5
		
		call findAllTHIS(3, finalAverage)
		average3 = finalAverage
		call findAllTHIS(4, finalAverage)
		average4 = finalAverage
		call findAllTHIS(5, finalAverage)
		average5 = finalAverage
end if				'---------------------------------------
	
sub breakdown()
	dim startHere
	dim endHere
	dim difference
	dim hole
	
		if rs("Round") = "Full" then 
			startHere = 1
			endHere = 18
		elseif rs("Round") = "Front" then
			startHere = 1
			endHERE = 9
		else
			startHERE = 10
			endHERE = 18
		end if
		
		set rs2 = Server.CreateObject("ADODB.Recordset")
		sql2 = "SELECT * from CourseHoles WHERE CourseID =" & rs("CourseID") & " AND Difficulty = 'Par'"
		rs2.Open sql2, conSQL
		
		for hole = startHere to endHere
			difference = cint(rs("H" & hole)) - cint(rs2("h" & hole))
			select case difference
				case -2
					eagleCount = eagleCount + 1
				case -1
					birdieCount = birdieCount + 1
				case 0
					parCount = parCount + 1
				case 1
					bogeyCount = bogeyCount + 1
				case 2
					doubleCount = doubleCount + 1
				case else
					otherCount = otherCount + 1
			end select
		next
		totalCount = eagleCount + birdieCount + parCount + bogeyCount + doubleCount + otherCount
		rs2.close
		set rs2 = nothing
end sub	
	
sub findCount(theCase1, theCase2, byref numRecords)
	numRecords = 0
	rs.movefirst
	while not rs.eof
		if rs("Round") = theCase1 or rs("Round") = theCase2 then numRecords = numRecords + 1
		rs.movenext
	wend
end sub
 
 
sub findAverage(theCase1, theCase2, theCount, byref theAverage)
	dim total
	total = 0
	rs.movefirst
	while not rs.EOF
		if rs("Round") = theCase1 or rs("Round") = theCase2 then total = total + cint(rs("Total"))
		rs.movenext
	wend
	if thecount = 0 then theAverage = 0 else theAverage = total/theCount
end sub
 
sub findLowest(theCase1, theCase2, byref theLowest)
	dim lowest
	rs.movefirst
	lowest = 1000
	while not rs.eof
		if rs("Total") < lowest and (rs("Round") = theCase1 or rs("Round") = theCase2) then lowest = rs("Total")
		rs.movenext
	wend
	if lowest = 1000 then theLowest = "-" else theLowest = lowest
end sub
 
sub findHighest(theCase1, theCase2, byref theHighest)
	dim highest
	rs.movefirst
	highest = -1000
	while not rs.eof
		if rs("Total") > highest and (rs("Round") = theCase1 or rs("Round") = theCase2) then highest = rs("Total")
		rs.movenext
	wend
	if highest = "-1000" then theHighest = "-" else theHighest = highest
end sub
 
sub findAllTHIS(findTHIS, finalAverage)
		dim grandTotal
		dim totalCountTHIS
		grandTotal = 0
		totalCountTHIS = 0
		rs.movefirst
		while not rs.eof
		recordTotal = 0
		countTHIS = 0
			call findTHISaverage(findTHIS, recordTotal, countTHIS)
			grandTotal = grandTotal + recordTotal
			totalCountTHIS = totalCountTHIS + countTHIS
			rs.movenext
		wend
		finalAverage = grandTotal/totalCountTHIS
end sub
 
sub findTHISaverage(findTHIS, recordTotal, countTHIS)
	dim startHere
	dim endHere
	
 
		if rs("Round") = "Full" then 
			startHere = 1
			endHere = 18
		elseif rs("Round") = "Front" then
			startHere = 1
			endHERE = 9
		else
			startHERE = 10
			endHERE = 18
		end if
		
		set rs2 = Server.CreateObject("ADODB.Recordset")
		sql2 = "SELECT * from CourseHoles WHERE CourseID =" & rs("CourseID") & " AND Difficulty = 'Par'"
		rs2.Open sql2, conSQL
		
		for hole = startHere to endHere
			if rs2("h" & hole) = findTHIS then 
				recordTotal = recordTotal + rs("H" & hole)
				countTHIS = countTHIS + 1
			end if
		next
		'response.write(recordTotal & "." & count3 & "..." )
		
		rs2.close
		set rs2 = nothing
end sub
 
		rs.close
		set rs = nothing
 
%>

Open in new window

0
Comment
Question by:RickyGtz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:bluV11t
ID: 22819761
Hi!
Could it be a case of zero devided by zero?

F.eks.
'This causes Devision by zero error
response.Write 2/0

'This causes no error
response.Write 0/2

'This causes overflow error
response.Write 0/0
0
 

Author Comment

by:RickyGtz
ID: 22822349
I know is caused by dividing something by zero. But I can't figure out what is wrong on my code.


	dim totalCountTHIS
		grandTotal = 0
		totalCountTHIS = 0
		rs.movefirst
		while not rs.eof
		recordTotal = 0
		countTHIS = 0
			call findTHISaverage(findTHIS, recordTotal, countTHIS)
			grandTotal = grandTotal + recordTotal
			totalCountTHIS = totalCountTHIS + countTHIS
			rs.movenext
		wend
		finalAverage = grandTotal/totalCountTHIS

Open in new window

0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22849579
Just do a check of grandTotal and totalCountTHIS first to avoid zero by zero division:
Replace line 13:

if (grandTotal == 0 && totalCountTHIS == 0){
finalAverage = 0;
}
else {
finalAverage = grandTotal/totalCountTHIS;
}
0
 

Author Comment

by:RickyGtz
ID: 22853975
hi thanks for your answer, how could i do the previous code on Classic ASP and Vbasic syntax....?
0
 
LVL 7

Accepted Solution

by:
bluV11t earned 500 total points
ID: 22861847
Oh! Sorry for posting JS code!

Try:

if grandTotal = 0 and totalCountTHIS = 0 then
finalAverage = 0
else
finalAverage = grandTotal / totalCountTHIS
end if
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question