473,383 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Performing Arithmetic on DataTable Columns

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?
Nov 18 '05 #1
2 2053
Nevermind, I discovered the Compute method.

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

"George Durzi" <gd****@hotmail.com> wrote in message
news:O3*************@TK2MSFTNGP11.phx.gbl...
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?

Nov 18 '05 #2
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" <gd****@hotmail.com> wrote in message
news:O3*************@TK2MSFTNGP11.phx.gbl...
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?

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Job Lot | last post by:
Is it possible to use Aggregate functions with GROUP BY Clauses on DataTable. I have a DataTable with following values: Date Amount Int Balance 1/1/2004 5000.00 50.00 5050.00...
1
by: M | last post by:
My problem is that AutogenerateColumns="false" does not work with the datatable I built from a hashtable. (Please don't ask why I'm pulling data from a database, putting it in a hashtable, then...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
2
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code...
1
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
2
by: Zorpiedoman | last post by:
If I have a string, "(5+3)/8" or "23>9" Has .NET provides some sort of parser that can get me the mathematical answer? Years ago, in VB6 I found an answer to this question using some sort of...
0
by: nil | last post by:
Help me.i am new to vb.net and i am developing one web application in vb.net2003. I am facing many problems in that so i would like to tell you one of them. I hope i will have the good response...
8
by: cj | last post by:
I have a program to display queries to a SQL db. I type my query in a textbox and click a button and the results display in a datagrid. I could use either dataset or datatable to read the data in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.