11
Answers

Error in null sum value

Mehmet Fatih

Mehmet Fatih

1y
571
1

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)