ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP 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 November 6th, 2009, 07:25 PM
nahhas82 nahhas82 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 36 nahhas82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 49 m 44 sec
Reputation Power: 3
Angry Add and substract problem...

hi my friends,

I had a database and I had two tables. in each table there is a column name "kilo" and type of the fields is number double decimal is 3. when I make a add function the result is true but when I make substract the result is so crazy and wrong. how I can solve this problem? can any body help me on this.

the code is athe below.

Code:

<%
strSQLTOTAL=""
strSQLTOTAL="select Sum(kilo) as sum_amount_remain from tbl_depo_giris_fisi where teslim_fisi_no="&RS_TESLIM_FISI_NO&""
set rsTOTAL=oConnection.execute(strSQLTOTAL)

If IsNull(rsTOTAL("sum_amount_remain")) = False Then
a=CDbl(rsTOTAL("sum_amount_remain"))
else
a=CDbl(0)
End If

%>

<%

strSQLTOTALBOYANMIS=""
strSQLTOTALBOYANMIS="select Sum(kilo) as sum_amount_kullanilan from tbl_renk_boyama_fisi_detay where teslim_fisi_no="&RS_TESLIM_FISI_NO&""
set rsTOTALBOYANMIS=oConnection.execute(strSQLTOTALBOY  ANMIS)

If IsNull(rsTOTALBOYANMIS("sum_amount_kullanilan")) = False Then
b=CDbl(rsTOTALBOYANMIS("sum_amount_kullanilan"))
else
b=CDbl(0)
end if
%>

<%

result_total=formatnumber(CDbl(a)-CDbl(b),3)

if result_total=0 or result_total<0 then
response.Write "<font color=""#FF0000"">" & result_total & "</font>"

else

response.Write result_total

end if

%>

Last edited by nahhas82 : November 6th, 2009 at 07:29 PM.

Reply With Quote
  #2  
Old November 7th, 2009, 02:22 AM
micky's Avatar
micky micky is offline
Couch Potato Wizard
Click here for more information. Click here for more information
 
Join Date: Jan 2005
Location: India
Posts: 12,259 micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)micky User rank is General 18th Grade (Above 100000 Reputation Level)  Folding Points: 1480 Folding Title: Novice Folder
Time spent in forums: 5 Months 4 Days 2 m 48 sec
Reputation Power: 2179
Can you post the values of a, b and result_total........ when you are subtracting and getting crazy results.
__________________
Laziness is my religion and Sunday is my God

Get the Mantra!

Reply With Quote
  #3  
Old November 9th, 2009, 09:52 AM
Jonathan8146 Jonathan8146 is offline
Contributing User
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2005
Posts: 1,708 Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level)Jonathan8146 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 3 h 50 m 45 sec
Reputation Power: 177
Try this and see if it works
Code:
<%
strSQLTOTAL=""
strSQLTOTAL="select ISNULL(Sum(kilo),0) as sum_amount_remain from tbl_depo_giris_fisi where teslim_fisi_no="&RS_TESLIM_FISI_NO&""
set rsTOTAL=oConnection.execute(strSQLTOTAL)

a=rsTOTAL("sum_amount_remain")
%>

<%

strSQLTOTALBOYANMIS=""
strSQLTOTALBOYANMIS="select ISNULL(Sum(kilo),0) as sum_amount_kullanilan from tbl_renk_boyama_fisi_detay where teslim_fisi_no="&RS_TESLIM_FISI_NO&""
set rsTOTALBOYANMIS=oConnection.execute(strSQLTOTALBOY    ANMIS)

b=rsTOTALBOYANMIS("sum_amount_kullanilan")
%>

<%

result_total=a-b

if result_total<=0 then
response.Write "<font color=""#FF0000"">" & formatnumber(result_total,3) & "</font>"

else

response.Write formatnumber(result_total,3)

end if

%>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Add and substract problem...


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





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek