Forums

ASP

This topic is locked

adding records

Posted 14 Mar 2006 18:32:53
1
has voted
14 Mar 2006 18:32:53 Javier Castro posted:
Hi,
Just when you think something is working, suddenly something new comes along.
this is my situation: I want to add intQuantity of all records that have the same prodID. I have tried all sort of variations but I don't seem to get it. I would imagine that it must be simple, that's why I can't get it.

SELECT SUM ( intQuantity) AS ItemTotal
FROM tblOrders
WHERE prodID

Or can I do that in ASP? doing something like<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>my example doen't work)
&lt;%= (rsOrders("intQuantity" + rsOrders("intQuantity") %&gt;

in the mean time I'll be looking around for an answer to my lack of know how.

Javier

Replies

Replied 23 Mar 2006 01:30:24
23 Mar 2006 01:30:24 micah santos replied:
&lt;%
Dim prodName, qtyCtr
qtyCtr = 0

rs.Open "SELECT * FROM TBL_RECORDS where prodID='" & prodName & "'", conn,1

Do until rs.EOF

If rs("prodID" = prodName Then
qtyCtr = qtyCtr + 1
End If

rs.MoveNext
Loop

If qtyCtr = 0 Then
qtyCtr = 0
End If

rs.close
set rs = nothing
%&gt;
Replied 23 Mar 2006 20:14:00
23 Mar 2006 20:14:00 John Shipp replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,
Just when you think something is working, suddenly something new comes along.
this is my situation: I want to add intQuantity of all records that have the same prodID. I have tried all sort of variations but I don't seem to get it. I would imagine that it must be simple, that's why I can't get it.

SELECT SUM ( intQuantity) AS ItemTotal
FROM tblOrders
WHERE prodID

Or can I do that in ASP? doing something like<img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>my example doen't work)
&lt;%= (rsOrders("intQuantity" + rsOrders("intQuantity") %&gt;

in the mean time I'll be looking around for an answer to my lack of know how.

Javier


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 24 Mar 2006 15:45:09
24 Mar 2006 15:45:09 Javier Castro replied:
Hi Micah for the reply. I can happily say that after a very long time trying, a friend and I got ot working using an Query instead, but the query was more complex than I anticipated. here it goes:

SELECT Products.product_code, SUM(tblOrders.intQuantity) AS TotalOrder
FROM Products INNER JOIN tblOrders ON Products.product_code = tblOrders.prodID
WHERE prodcat ='MMColParam' GROUP BY Products.product_code

---------------------------------------------------------------------------------
MMColParam 0 Request.QueryString("prodcat"


Thanks for your help,

Javier
Replied 24 Mar 2006 23:19:53
24 Mar 2006 23:19:53 micah santos replied:
you're very much welcome! anything i can do to help is my pleasure, though, i'm not that really good in ASP as far as i can tell. but this is my way to learn asp scripts too.

Reply to this topic