I am trying to use sql to sum a column in my access database and put the result of this in a text box. The code I have got is the following, but this is coming up with the error below.
Error : Conversion from type 'DBNull' to type 'String' is not valid.
dbCommand = New OleDbCommand
dbCommand.Connection = New OleDbConnection(DataBase)
dbCommand.Connection.Open()
dbCommand.CommandText = "SELECT SUM(TransactionAmount) FROM Transactions WHERE Budget='" & cmbBudget.Text & "'"
Reader = dbCommand.ExecuteReader
While Reader.Read
TextBox1.Text = Reader.GetValue(0)
End While
The (DataBase) reference is working correctly, as there is a previous SQL command above this one.
Any help much appreciated!!!!!