Posted on: 1/15/2014 11:54:41 PM | Views : 604

I am trying to execute this command.
oCommand.Parameters.Add("@actFinish", SqlDbType.Date).Value = IIf(Trim(row.Cells(5).FindControl("actFinish_TextBox").Text) <> "", CDate(row.Cells(5).FindControl("actFinish_TextBox").Text), System.DBNull.Value) It works fine when the textbox in question is populated with a valid date but fails when the textbox is empty. It seems no matter what I place in the condition, the CDate function tries to execute and convert the empty string to a date which then fails. Can someone advise me on how to get this to work? I want to save a date if the textbox is populated or a null if it is not.
Thanks

Go to the complete details ...