Click to See Complete Forum and Search --> : SQL/ASP Calculated query question


mangofreak
01-12-2006, 12:13 PM
Hi,
I am working on an ordering system with no transaction. I have been able to develop the database and the ordering form and works fairly well. What the system does is:
A user logs into the site, places and order from our catalogue into an insert form with the option for inputing product code and quantity. I keep track of the order by Session information. Everytime a record is inserted a query multiplies unit price by quantity ordered and gives a line result or individual result. Another query adds all the line results into a subtotal, and I am trying to come up with a query that would calculate the taxes for the order.

There are 3 types of taxes depending on the province the user is from.

The query below works half way because it only calculates one time. What I want is to calculate for every order. I'm using Access/ASP and Ddreamweaver MX 2004. Please if anyone can help me would be great. I've been working on this for a week now and I don't seem to get anywhere.

<%
Dim rsSubGST__MMColParam
rsSubGST__MMColParam = "0"
If (Session("MM_intUserID") <> "") Then
rsSubGST__MMColParam = Session("MM_intUserID")
End If
%>
<%
Dim rsSubGST
Dim rsSubGST_numRows

Set rsSubGST = Server.CreateObject("ADODB.Recordset")
rsSubGST.ActiveConnection = MM_connStuff_STRING
rsSubGST.Source = "SELECT (intQuantity * catalogue_price * GST/100) AS GSTsub FROM tblOrders, Products, tblProvince WHERE prodID = product_code AND userID = " + Replace(rsSubGST__MMColParam, "'", "''") + ""
rsSubGST.CursorType = 0
rsSubGST.CursorLocation = 2
rsSubGST.LockType = 1
rsSubGST.Open()

rsSubGST_numRows = 0
%>

chrismartz
01-12-2006, 07:24 PM
I think when you change the amount of items that you have, you will need to refresh the page so it can go back through your sql query.

mangofreak
01-13-2006, 09:44 PM
Thanks for the reply. That's what I though but it doesn't work. I have come to believe that I need to create some kind of function that instead of calculating the taxes for each entry, it will calculate the taxes for the subtotal. The problems is , I don't know how to create function using ASP. If anyone has a sample oe lead as to where to find one, it will be very much appreciated.


Javier