Dealy

Dealy

  • NA
  • 213
  • 0

Error on null values (when format is date)

Oct 16 2009 1:23 AM
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)