View Single Post
  #1 (permalink)  
Old 05-04-10, 08: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..
Reply With Quote