Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Performing Arithmetic on DataTable Columns

Reply
Thread Tools

Performing Arithmetic on DataTable Columns

 
 
George Durzi
Guest
Posts: n/a
 
      06-07-2004
I have a DataTable with only one DataColumn of type float. I need to
calculate the Max value that in any of the DataRows, and this DataColumn.

I noticed the DataColumn has an Expression property:
http://msdn.microsoft.com/library/de...ssionTopic.asp

However, it seems that I would end up having to create a new DataColumn,
call it MaxVal or something, and populate it for every row.

Is there a cleaner way?


 
Reply With Quote
 
 
 
 
George Durzi
Guest
Posts: n/a
 
      06-07-2004
Nevermind, I discovered the Compute method.

float flMax =
(float)m_dsSegments.Tables["Calculations"].Compute("Max(Score)",
string.Empty);



"George Durzi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a DataTable with only one DataColumn of type float. I need to
> calculate the Max value that in any of the DataRows, and this DataColumn.
>
> I noticed the DataColumn has an Expression property:
>

http://msdn.microsoft.com/library/de...ssionTopic.asp
>
> However, it seems that I would end up having to create a new DataColumn,
> call it MaxVal or something, and populate it for every row.
>
> Is there a cleaner way?
>
>



 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      06-07-2004
If your contents are bound to a dataset why don't you just use the dataset
ds.Tables[0].Compute("Max(["+strColumnName+"])",String.Empty)

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"George Durzi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a DataTable with only one DataColumn of type float. I need to
> calculate the Max value that in any of the DataRows, and this DataColumn.
>
> I noticed the DataColumn has an Expression property:
> http://msdn.microsoft.com/library/de...ssionTopic.asp
>
> However, it seems that I would end up having to create a new DataColumn,
> call it MaxVal or something, and populate it for every row.
>
> Is there a cleaner way?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a datatable and create a new datatable Fredrik Rodin ASP .Net 3 09-28-2007 07:28 AM
Usual Arithmetic Conversions-arithmetic expressions joshc C Programming 5 03-31-2005 02:23 AM
Create a Datatable from a SQL datatable column shema? jg ASP .Net 1 08-17-2004 09:43 PM
Casting DataTable to class inherit from DataTable =?Utf-8?B?Qmx1ZWZsb3dlcg==?= ASP .Net 0 04-02-2004 05:41 AM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM



Advertisments