问题
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