Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top