This is topic ASP .net compute method in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=050654

Posted by Blayne Bradley (Member # 8565) on :
 
code:
lblTotal.Text = gt.Compute("SUM(QuantityOrdered)", "QuantityOrdered Is Like'" & ddlPr_Name.SelectedValue & "'")

Basically I wanna sum up all the values in a datatable corresponding only for a certain column.
 
Posted by TomDavidson (Member # 124) on :
 
And...?

(Edit: look at your code, Blayne.)
 
Posted by Blayne Bradley (Member # 8565) on :
 
the command as is, and varitions of it playing with syntax gives me an error

"Cannot perform 'Like' operation on System.Int32 and System.String."
 
Posted by TomDavidson (Member # 124) on :
 
You have two problems with this code.
First off, QuantityOrdered is almost certainly an Integer field; you can't use "is like" operators on an Integer. Secondly, you're checking the QuantityOrdered column against the SelectedValue property of the ddlPr_Name field, which is probably a dropdown list of products.

My guess is that you want to sum the QuantityOrdered field across only (and all) the records that correspond to the ProductID of the item selected from the dropdown, which is the SelectedValue of ddlPr_Name.

If that's the case, what you really want is....

Okay, wait. You figure the rest out.
 
Posted by Lisa (Member # 8384) on :
 
So... the old rule about not helping people with homework has been repealed? Cool.
 
Posted by TomDavidson (Member # 124) on :
 
I've never considered it a rule, and certainly never let it bind me.
 
Posted by Blayne Bradley (Member # 8565) on :
 
code:
lblTotal.Text = gt.Compute("SUM(QuantityOrdered)", "ProductName Like '" & ddlPr_Name.SelectedValue & "'")

Thanks for pointing me in the right direction.
 
Posted by Blayne Bradley (Member # 8565) on :
 
K, if I upload asp files to a linux server, how can I get it to work as a webpage, non homework related I just wanna put my work online so employers can look at it.
 
Posted by MattP (Member # 10495) on :
 
Um... a Linux server is not going to be able to host asp files unless you just have static HTML content.
 
Posted by Nighthawk (Member # 4176) on :
 
I've been told that it can; aren't there ASP and ASP.NET interpreters for Linux already?
 
Posted by MattP (Member # 10495) on :
 
Well, there's Mono. I have no experience with it so I can't say what's involved there.
 
Posted by Reshpeckobiggle (Member # 8947) on :
 
[Confused]
 
Posted by TomDavidson (Member # 124) on :
 
BTW, from a design perspective, you probably don't want to make ProductName the SelectedValue of your dropdownlist. The value should be the ProductID, assuming you have one.
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2