So if you have ever seen this goddamn error before, then you might have been tempted to pull your hair out while screaming, “WHY WON’T THIS FUCKING WORK!” Especially when you see a goddamn example of it on the MSDN white pages:
For some people this is a very obvious error, “Oh stupid me, its so clear I am trying to take the sum of a column with a data type of string, oops!” But for people like me, when you are trying to get 100 things done all at the same time a stupid ass error like this can trip you up. So this is just a heads up on DataTables, make sure your DataTable’s data is strongly typed so that you don’t run into silly problems like this one.
Additionally when using the DataTable.Compute() method think of it this way: DataTable.Compute([Aggregate Function for ONE column only], [WHERE clause]), easiest way to think about it in my opinion. Keep it simple, no fancy stuff, this isn’t real SQL.

Leave a Reply

Your email address will not be published. Required fields are marked *