Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2005, 07:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Overflow Error

Please help, how can control the overflow eroor in the following
coding ?


Error Type:
Microsoft VBScript runtime (0x800A0006)
Overflow
/tabulation/bmhours/PWMH2.asp, line 226


coding
-------
Query is
---------

dim total11, total12, totalBH1 //all variables have defined.

ssql="select a.projno, e.Name, e.userid, e.dept,a.empno,b.dated,b.bh,sum(mh1) mh1 ,sum(MH2) MH2,sum(MH3) MH3,sum(MH4) MH4 ,sum(MH5) MH5 ,sum(total) total from (select empno ,projno ,mh1 = case when b.weekno = 1 then a.mh1 else 0 end ,MH2 = case when b.weekno = 2 then a.mh1 else 0 end ,MH3 = case when b.weekno = 3 then a.mh1 else 0 end ,MH4 = case when b.weekno = 4 then a.mh1 else 0 end ,mh5 = case when b.weekno = 5 then a.mh1 else 0 end ,total = a.mh1 from mh1 a JOIN weeks b ON a.dated = b.dated) a JOIN bh b ON a.empno = b.empno AND a.projno = b.projno JOIN Emp e ON a.empno = e.empno where b.dated='"& DATED &"' and a.projno='"& projno &"' group by a.projno ,e.dept,e.name,e.userid, a.empno,b.bh,b.dated order by e.DEPT,E.NAME,a.projno"


set rs=cn.Execute(ssql)

IF NOT RS.EOF THEN
do while rs.eof=false


Response.Write("<td align=center>" & rs("empno") & "</td>")
Response.Write("<td>" & rs("Name") & "</td>")
Response.Write("<td>" & rs("userid") & "</td>")
Response.Write("<td>" & rs("dept") & "</td>")
Response.Write("<td align=center>" & rs("BH") & "</td>")

totalBH1=rs("BH")

Response.Write("<td align=center>" & rs("mh1") & "</td>")
Response.Write("<td align=center>" & rs("mh2") & "</td>")
Response.Write("<td align=center>" & rs("mh3") & "</td>")
Response.Write("<td align=center>" & rs("mh4") & "</td>")
Response.Write("<td align=center>" & rs("mh5") & "</td>")

Response.Write("<td align=center>" & rs("total") & "</td>")

total11=rs("total")

Response.Write("<td>" & total11 & "</td>")
Response.Write("<td>" & totalBH1 & "</td>")

total12 = (total11/totalBH1)*100 // error is line no.226

Response.Write("<td>" & total12 & "</td>")

rs.movenext
loop



I want to calculate percentage in loop.

total12 = (total11/totalBH1)*100

total12 ie percentage of each row should be dipslay how ?

with sincere regards.

Mateen










 
Old July 4th, 2005, 05:59 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Ive seen types of overflow errors like stack overflow and cint overflow, nerver just overflow - is that all the error says?

Wind is your friend
Matt
 
Old July 5th, 2005, 12:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.

it is cint overflow error.

problem is that some rs("BH") value is zero. ie

totalBH1=rs("BH")
totalBH1= 0

and we can not divid by zero ie

total12 = (total11 / 0 )*100

how can control the loop/calculation that if rs("BH) received
zero value from the table it not give error,
or it display zero after divid how ?
or it display message/print messsge in
that column ie Response.Write("<td>" & total12 & "</td>")

total12=not divided by zero how ?
or only display zero how ?

with regards.

Mateen




 
Old July 5th, 2005, 01:11 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Use a condition inside the loop, something like:

if (cint(totalBH1) > 0) then
   total12 = (total11/totalBH1)*100
else
   total12 = "cant calculate"
end if

Wind is your friend
Matt
 
Old July 5th, 2005, 02:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot.

regards.

Mateen







Similar Threads
Thread Thread Starter Forum Replies Last Post
Arithmetic overflow error gregalb Reporting Services 1 June 24th, 2008 02:42 PM
Find with overflow error EricB123 Excel VBA 0 July 20th, 2007 10:34 AM
Unsolved OverFlow Error maggiefeng Classic ASP Basics 6 December 4th, 2006 07:45 PM
Odd arithmetic overflow error.... 7racer SQL Server 2000 4 May 12th, 2006 09:17 AM
can anybody tell why i am getting overflow error tulsi15 SQL Server 2000 1 December 15th, 2004 07:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.