Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我检索具有空 DataTime 字段的行时出现此错误:
“srRow.Closed_Date”引发了“System.Data.StrongTypingException”类型的异常
我该如何正确处理这些?
您可以在检索值之前检查该列中的空值。
if (!srRow.IsClosed_DateNull()) { myDate = srRow.Closed_Date; }
这里有一个参考。
或者,您是否可以使用 IsNull 运算符修改查询以确保结果不为空?
Select (IsNull, SomeDateField, GetDate())
假设您使用的是 .NET,则可以在这种情况下使用SqlType 。