Crystal report not support null Datetime

喜你入骨 提交于 2019-12-20 05:13:35

问题


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.

Like:-

 _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();

throwing error here......

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"),

then Crystal report not supporting.

having any best solution?


回答1:


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.



来源:https://stackoverflow.com/questions/16882891/crystal-report-not-support-null-datetime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!