Crystal报表不支持null DateTime [英] Crystal report not support null Datetime
本文介绍了Crystal报表不支持null DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ado.Net的水晶报表,当datetime从数据库中变为空时显示错误。如果我们使用Nullable(使用?)属性,那么水晶报表不能支持。
I am using crystal report with ado.Net, when datetime is coming null from database then showing error. if we use Nullable (using ?) property then crystal report can't support.
喜欢: -
_report = (
from user in users
select new userModel()
{
UserId = user.Field<string>("userid"),
CheckInTime = <user.Field<DateTime>("intime"),
CheckOutTime = user.Field<DateTime>("outime"),
TotalWorks = user.Field<Int32>("TotalWork")
})
.ToList();
这里抛出错误......
,当我们使用Nullabe ..: -
and when we use Nullabe..:-
public DateTime? CheckInTime { get; set; }
public DateTime? CheckOutTime { get; set; }
CheckInTime = <user.Field<DateTime?>("intime"),
CheckOutTime = user.Field<DateTime?>("outime"),
然后Crystal报表不支持。
then Crystal report not supporting.
推荐答案
最简单的方法是将该日期变量转换为字符串(如果为null,则将其变为空),然后再传递给水晶报表,并将其用作水晶报表中的字符串。
Easiest way is to convert that date variable to string (and make it blank if null), before passing it to crystal report, and use it as a string in crystal report.
这篇关于Crystal报表不支持null DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文