简体   繁体   English

null 值不能分配给 System.DateTime 类型的成员,该类型是不可为空的值类型

[英]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.

相关问题 无法将null值分配给类型为System.Int64的成员,该成员是非可空值类型 - The null value cannot be assigned to a member with type System.Int64 which is a non-nullable value type 无法将null值分配给类型为System.Boolean的成员,该类型是不可为空的值类型 - The null value cannot be assigned to a member with type System.Boolean which is a non-nullable value type 无法将null值分配给类型为System.Int32的成员,该类型是非可空值类型 - The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type LINQ错误:无法将null值分配给类型为System.Int32的成员,该成员是非可空值类型 - LINQ error: The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type LINQ中不一致的错误,不能将空值分配给类型为System.Int32的成员,该类型是非空值类型 - Inconsistent error in LINQ the null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type 例外:不能将空值分配给类型为System.Int32的成员,该类型是非空值类型 - Exception: The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type “无法将null值分配给System.Int32类型的成员,该类型是不可为空的值类型。” - “The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type.” 无法将null值分配给类型为decimal的成员,该成员是非可空值类型 - The null value cannot be assigned to a member with type decimal which is a non-nullable value type 不可为空的System.DateTime的值 - Value for Non-Nullable System.DateTime 无法将空值分配给C#中类型为System.DateTime的成员 - The null value cannot be assigned to a member with type System.DateTime in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM