Data source - datetime(nullable)

Stimulsoft Reports.NET discussion
Post Reply
pvasek
Posts: 9
Joined: Tue Jul 03, 2012 6:27 am

Data source - datetime(nullable)

Post by pvasek »

Hi All,

what do I need to do to add data source which will have column set to datetime(nullable)?

I tried to set AllowDbNull = true for the column but that didn't work.

Any ideas? Thank you!

Pavel
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Data source - datetime(nullable)

Post by HighAley »

Hello.

What Data Source do you use?
Where do you set the AllowDbNull property?
Could you provide any details else to reproduce the issue.

Thank you.
pvasek
Posts: 9
Joined: Tue Jul 03, 2012 6:27 am

Re: Data source - datetime(nullable)

Post by pvasek »

Hi Aleksey,

I am using method RegData of StiReport and passing System.Data.DataTable.

something like this:

Code: Select all

var report = new StiReport();
report.Load("myreport.mrt");
var data = new DataTable();
data.Columns("Date", typeof(DateTime)).AllowDbNulls = true;
data.Rows.Add(new DateTime(2003, 10, 25));
data.Rows.Add(DBNull.Value);
report.RegData(data);
The problem is on the second added row where the value is null and the report fails to render with message :
Expression in Text property of 'TableNumberOfEntriesByNoc_Cell12' can't be evaluated! Object reference not set to an instance of an object.
If I change the type for the given column in the report designer to datetime(nullable) it works fine. But I need to set it from code. I thought that setting AllowDbNulls will make the effect but it doesn't.

Thanks for your help!

Pavel
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Data source - datetime(nullable)

Post by Alex K. »

Hello,

DataSet does not support System.Nullable<>.
In this case, you can set the DateTime(Nullable) type of column in dictionary in designer.

Thank you.
User avatar
zalak
Posts: 18
Joined: Wed Jun 20, 2018 1:41 pm

Re: Data source - datetime(nullable)

Post by zalak »

Hello,

Any updates on this one
Alex K. wrote: Mon Oct 08, 2012 9:44 am Hello,

DataSet does not support System.Nullable<>.
In this case, you can set the DateTime(Nullable) type of column in dictionary in designer.

Thank you.
We are facing the same issue.
We need the column to have datetime(nullable) which should be set from the code and not in the designer. We are using the same method mentioned above by 'pvasek' to get datasource for the report.
We are using version 2019.1.1.0.

Thanks & Regards,
Zalak
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Data source - datetime(nullable)

Post by Lech Kulikowski »

Hello,

Please try to set the following option:
StiOptions.Dictionary.UseAllowDBNullProperty = true;

Thank you.
Post Reply