Hi, I'm trying to get the sum of a column but access returns 3 rows and the SUM is located at the 2nd row of the 1st column (i tried binding it to a datagridview)
cmd.CommandText = "SELECT SUM(AmountDue) AS Total FROM Delivery WHERE ArrivalDate = " + DateTime.Today.Date.ToShortDateString() + ""
I decided to ignore this and went ahead and transferred the value to a variable
lblTotal.Text = dt.Rows(1)(0).ToString to match what I am seeing in the gridview. But when i run the program, I get an out of bounce error, so i change it to (0)(0) but when i run the program again, there is no value. I already resorted to doing a For loop which goes through every cell of the datatable and use an if dt.Rows(x)(y).ToString <> "" to get the value but to no avail
Any ideas what I'm doing wrong?
cmd.CommandText = "SELECT SUM(AmountDue) AS Total FROM Delivery WHERE ArrivalDate = " + DateTime.Today.Date.ToShortDateString() + ""
I decided to ignore this and went ahead and transferred the value to a variable
lblTotal.Text = dt.Rows(1)(0).ToString to match what I am seeing in the gridview. But when i run the program, I get an out of bounce error, so i change it to (0)(0) but when i run the program again, there is no value. I already resorted to doing a For loop which goes through every cell of the datatable and use an if dt.Rows(x)(y).ToString <> "" to get the value but to no avail
Any ideas what I'm doing wrong?