|Have you verified that your query string returns the appropiate data?
have appropiate values?
Sounds to me that ExecuteScalar is returning null.
According to the MSDN documentation[^] on the OleDbCommand:
The first column of the first row in the result set, or a null reference if the result set is empty.
Check if it is indeed returning null, if it is, check your input.
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez