8
Answers

Error on null values (when format is date)

Ask a question
Dealy

Dealy

14y
4.4k
1
Hello,

how can I handle null values in the following code? The problem is if user don't fill the textfield (end_date.Text) i get an error message even thought END_DATE database field is nullable.


SqlCommand command = new SqlCommand(sproc, conn);
command.CommandType = CommandType.StoredProcedure;

command.Parameters.Add("@END_DATE",SqlDbType.DateTime).Value = Convert.ToDateTime(end_date);
//end_date is a string


Thank you in advance.

Answers (8)