Hello,
I'm trying to send a Null value in a DateTime field while calling my stored procedure.
If I use this first method (short with one line), i got the following error message:
Error Message:
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DateTim e' and 'System.DBNull'
However, it works correctly if I use the 2nd method:
Can you help me to fix the problem with the first method ?
Thank you
Paul
I'm trying to send a Null value in a DateTime field while calling my stored procedure.
If I use this first method (short with one line), i got the following error message:
Code:
cmd.Parameters["@p_order_date"].Value = (this.OrderDate == DateTime.MaxValue) ? DBNull.Value : this.OrderDate;
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DateTim e' and 'System.DBNull'
However, it works correctly if I use the 2nd method:
Code:
if (this.OrderDate == DateTime.MaxValue) { cmd.Parameters["@p_order_date"].Value = DBNull.Value; } else { cmd.Parameters["@p_order_date"].Value = this.OrderDate; }
Can you help me to fix the problem with the first method ?
Thank you
Paul