DataTable.Compute - the filter parameter
Following on from my original posting about using the Compute method of the DataTable to execute aggregate queries, I should add that, the 2nd argument is mandatory as per the docco here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataTableClassComputeTopic.asp
The filter parameter is the equivalent to a WHERE clause that you can use to limit the number of records that are returned to the aggregate expression. The example I gave in my previous posting was a good example of this where I used a LIKE expression in the filter parameter to get a count of persons whose name met a given criteria:
int countOfName = (int) dt.Compute("Count(Name)", "Name Like '" + entryTextBox.Text + "*'") ;
If the filter is not required, you must pass an empty string as the argument:
eldestYear.Text = dt.Compute( "MAX(DateOfBirth)", "" ).ToString() ; youngestYear.Text = dt.Compute( "MIN(DateOfBirth)", "" ).ToString() ;