[英]The null value cannot be assigned to a member with type System.DateTime which is a non-nullable value type
var Ceremony = dc.GetOneCeremony(IdCeremony);
when run the top line show this error:运行顶行时显示此错误:
The null value cannot be assigned to a member with type System.DateTime which is a non-nullable value type. null 值不能分配给 System.DateTime 类型的成员,该类型是不可为空的值类型。
if you have a property Ceremony class that has DateTime type change it to DateTime?如果您有一个具有 DateTime 类型的属性 Ceremony class 将其更改为 DateTime? it seems GetOneCeremony returns an object that has null datetime field似乎 GetOneCeremony 返回具有 null 日期时间字段的 object
you're probably assigning a null value from a datareader to a datatime datatype.您可能正在将来自数据读取器的 null 值分配给数据时间数据类型。
something like:就像是:
DateTime dt = (DateTime)yourDataReader["YourDateTimeColumnWhichIsNull"].Value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.