我這裏這行代碼:使用日期時間與空
command.Parameters["@DateCompleted"].Value = items[i].DateCompleted.Equals("01/01/0001 12:00:00 AM") ? null : items[i].DateCompleted;
,但我得到這個錯誤:
Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'System.DateTime'
我所試圖做的是不使用01/01/0001日期和使用null,因爲該項目爲空。
附加代碼:
command.Parameters.Add("@DateCompleted", System.Data.SqlDbType.DateTime);
聽起來像是你需要看看下面的[可空結構](http://msdn.microsoft.com/en-us/library/ b3h38hb0.aspx) –
MethodMan