0

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!!!!!

4
Contributors
5
Replies
22
Views
9 Years
Discussion Span
Last Post by leninalberto
0

Ah thanks for your reply,but I am confused. What do you mean/ what do I need to do?

Thanks for your reply, I appreciate it :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.