Hi and good day,
I have a piece of code im working on and is stuck on Select Sum statement which keeps returning a Conversion from type DBNull to type Decimal is invalid. Below is the code and Im working with a Access Database. Everything works good if the Batch Number exists and its when the Batch Number does not exist.
Thanks in Adavance
Ken
mycmd = New OleDb.OleDbCommand("SELECT SUM([Production This Session]) AS [Production This Session], SUM([Total Units]) AS [Total Units] FROM SBInput WHERE [Batch Number] = '" & TextBox6.Text & "'", mycon)
mycon.Open()
Dim mydr As OleDb.OleDbDataReader = mycmd.ExecuteReader
If mydr.Read = True Then
TBP = mydr("Production This Session")
TextBox14.Text = TBP.ToString("##,###.##0")
TU = mydr("Total Units")
TextBox15.Text = TU.ToString("##")
End If
If mycon.State <> ConnectionState.Closed Then
mycon.Close()
End If