Hi, I want tot find the sum of a colum in a datagrid. Below is the code that I am using but the problemm is that if there is no data in the table, it does not work. I get the error message: Cast from type 'DBNull' to type 'Decimal' is not valid.
TotalSoldPrice = objDS.Tables(0).Compute("SUM(SoldBid)", String.Empty).ToString
txtTotalSoldPrice.Text = FormatCurrency(TotalSoldPrice)
Can you tell me how I can get around this. I want to use this code because it is the simplest one that I have found thus far.
P.S, I am using SQL database, SQL Server 2003 and APS.NET and VB.NET