Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: Intermediate
Mar 17, 2003



Application Security Testing: An Integral Part of DevOps

The DataTable's Compute method

The DataTable class has a method, Compute, that executes SQL-like functions on the rows locally stored in the DataTable. It supports functions such as COUNT, SUM, MIN, MAX, AVG and others. Here's an example to calculate the average salary for the employees stored in the tableEmployees DataTable:

Dim maxSalary As Integer = CType(tableEmployees.Compute("AVG(Salary)", ""), _
The Compute method takes in a second parameter, which is a filter expression. For example, this is how to calculate the number of employees with a salary greater than $5,000:

Dim numLuckyEmployees As Integer = CType(tableEmployees.Compute _
    ("COUNT(EmployeeID)", "Salary > 5000"), Integer)
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date