ASP.NET C#: DataTable Compute

If you want to perform a sum or count on the records in a DataTable, you can, very simply. You’ll have to have a DataTable with something in it, like results from a database, then you do this: // my DataTable is full of customer data and is named "dt" object newCustomerCount = dt.Compute("count(id)","CustomerID > [...]

ASP.NET C#: Using DataTable

To auto-close a datatable after it is done being used (as well as creating a DataTable), a using statement is most helpful. using (DataTable dt = new DataTable()){ //your datatable specific code here }