Current location: Hot Scripts Forums » Programming Languages » ASP » ASP sql subtraction ms access database


ASP sql subtraction ms access database

Reply
  #1 (permalink)  
Old 05-04-10, 09:15 PM
jerrold jerrold is offline
New Member
 
Join Date: Jan 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ASP sql subtraction ms access database

please hel me.. Please



i have two table

1) Table1
field name
1) FreeBag = 100
2) BuyBag = 50
the total is 150

2) Table2
field name
1) DeliveredBag = 200

subtract the 200-150 i want the output is 50

this is my code

<table>
<%
Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open "FILEDSN=c:/dsn/MyTable_dsn.dsn"
SQL_query = "SELECT SUM(BuyBag+FreeBag-DeliveredBag)AS Total FROM Table1, Table"



Set RS = MyConn.Execute(SQL_query)
WHILE NOT RS.EOF
%>
<tr>
<td>Total Bag Remain</td>
<td><%=RS("Total")%>&nbsp;</td>
</tr>
<%
RS.MoveNext
WEND
RS.Close
MyConn.Close
%>
</table>

what is the wrong of my code?
Please help me... Thank you..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-10-10, 08:05 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Well the first thing I see is you have two tables named "Table1" and "Table2".
But in your query string you have "Table1" and "Table".
As long as you only have one entry in your table fields then your query should work fine.
And you don't need the WHILE loop because you are getting only one result.
But if you are trying to use the WHILE loop because you have more than one entry in each table field, then the SUM command will not give you the expected results.
And you will have to SUM each field and do your calculations in your output instead of the query.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to create an upload function that writes to MS access database KamalRahman ASP.NET 1 05-07-09 04:11 AM
ASP (Microsoft Access) Question rjackson1104 ASP 3 09-18-06 01:05 PM
Access to SQL Script conversion PaniXOH PHP 1 11-16-03 07:30 AM
Script Conversion: Access Database/Now to SQL PaniXOH ASP 1 11-14-03 10:35 PM
SQL database registration form help vinhkhuong PHP 3 10-10-03 04:49 AM


All times are GMT -5. The time now is 12:30 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.