Mehmet Fatih

Mehmet Fatih

  • 857
  • 939
  • 41k

Error in null sum value

Apr 7 2023 3:35 PM

I want to get the total of the books in the database using sum but if there is no book in the database, it gives error. I want it to write 0 instead of error. My codes are below.

OleDbCommand cmd = new OleDbCommand("select sum(adet) from kitaplar25", conn);
                cmd.Parameters.AddWithValue("@adet", label14.Text);
                label14.Text = cmd.ExecuteScalar().ToString();


Answers (11)