DateTime column: why dictionary type is not "datetime (nullable)"?
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
DateTime column: why dictionary type is not "datetime (nullable)"?
In Vs2005 I have a datatable with a datetime column. The column's ".AllowDBNull" property is true.
If a pass this datatable (regdata) to a report for designing, in dictionary i see that the column is "datetime" and not "datetime (nullable)" (i expected the nullable one).
This leads me to a problem: if the type in the dictionary is "datetime" (and not "datetime (nullable)") and i design this column using the default datetime format (the first one with an asterisk), when the value of the datetime column is null i don't see the empty field (i expected to see it empty) but i see "01/01/0001".
The question: why, though datatable column's "AllowDBNull" property is true, the column is created in dictionary as "datetime" and not "datetime (nullable)"?
Thanks.
If a pass this datatable (regdata) to a report for designing, in dictionary i see that the column is "datetime" and not "datetime (nullable)" (i expected the nullable one).
This leads me to a problem: if the type in the dictionary is "datetime" (and not "datetime (nullable)") and i design this column using the default datetime format (the first one with an asterisk), when the value of the datetime column is null i don't see the empty field (i expected to see it empty) but i see "01/01/0001".
The question: why, though datatable column's "AllowDBNull" property is true, the column is created in dictionary as "datetime" and not "datetime (nullable)"?
Thanks.
DateTime column: why dictionary type is not "datetime (nullable)"?
Unfortunately, we can't resolve this issue, because we use the types of ADO.NET and it haven't datetime(nullable) type.
Thank you.
Thank you.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
DateTime column: why dictionary type is not "datetime (nullable)"?
This means that i can't print an empty field when the date is null? Is there any workaround you can suggest?
Thanks.
Thanks.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
DateTime column: why dictionary type is not "datetime (nullable)"?
But in designer i see type "datetime (nullable)" in the column:Unfortunately, we can't resolve this issue, because we use the types of ADO.NET and it haven't datetime(nullable) type.

If i set this, all works fine (when date is null the field is left blank) but if i leave the default "datetime" (taken from the datatable passed in regdata, though datecolumn.AllowDBNull is "True"), when the date is null it prints "01/01/0001".
Anyway, while waiting for the answer, i was thinking for a workaround: after "regdata" i could iterate through all columns in dictionary's datasource and, when i find a column with "datetime" type, force it with "datetime (nullable)" type. Is it possible?
Thanks.
DateTime column: why dictionary type is not "datetime (nullable)"?
What happens when you try this piece of code in your application?
when the Designer loads just drag the Datasource onto the empty page with the 2 columns and do a preview. Does it render empty DateTime fields or "01/01/0001"
For me null dates in my datatables have always shown as empty fields.
Code: Select all
Dim tableDate As New DataTable("DateTable")
tableDate.Columns.Add("ID", GetType(Integer))
tableDate.Columns.Add("NullDate", GetType(DateTime)).AllowDBNull = True
tableDate.Rows.Add(1, DateTime.Now)
tableDate.Rows.Add(2, DateTime.Now)
tableDate.Rows.Add(3, DateTime.Now)
tableDate.Rows.Add(4, DBNull.Value)
tableDate.Rows.Add(5, DBNull.Value)
tableDate.Rows.Add(6, DateTime.Now)
Dim report As New Stimulsoft.Report.StiReport()
report.RegData("MyData", tableDate)
report.Design()
For me null dates in my datatables have always shown as empty fields.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
DateTime column: why dictionary type is not "datetime (nullable)"?
Brendan, with your suggestion i think i have found the problem: it happens only if report scripting language is VB (i use that).
To your code:
add the following line after report variable declaration:
You'll see the problem: all null dates are printed as "01/01/0001".
I'm using released version 2007.2 for Vs2005.
Thank you very much Brendan, waiting for a fix if this possible bug is confirmed.
To your code:
Code: Select all
Dim report As New Stimulsoft.Report.StiReport()
report.RegData("MyData", tableDate)
report.Design()
Code: Select all
report.ScriptLanguage = Stimulsoft.Report.StiReportLanguageType.VB
I'm using released version 2007.2 for Vs2005.
Thank you very much Brendan, waiting for a fix if this possible bug is confirmed.
DateTime column: why dictionary type is not "datetime (nullable)"?
In this case try setting the property of the report "ConvertNulls" to false.
The CType function in VB seems to return a DateTime of 1/1/1 if you specify a null value or "Nothing" for the expression.
The CType function does not exist in C# so a direct cast is done instead and fails when the value is null.
The CType function in VB seems to return a DateTime of 1/1/1 if you specify a null value or "Nothing" for the expression.
The CType function does not exist in C# so a direct cast is done instead and fails when the value is null.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
DateTime column: why dictionary type is not "datetime (nullable)"?
That makes sense to all, and works.
Thanks to all.
Thanks to all.
Re: DateTime column: why dictionary type is not "datetime (n
Sorry for bringing this discussion up again!
I am on 2017.2.3.
When I try calling RegData for my business object, the double? is not converted to "double (nullable)", instead, it remains double. This causes a confusion for us to know whether the data was actually 0 or was null.
Can you please help?
Cheers
Vineet
I am on 2017.2.3.
When I try calling RegData for my business object, the double? is not converted to "double (nullable)", instead, it remains double. This causes a confusion for us to know whether the data was actually 0 or was null.
Can you please help?
Cheers
Vineet
Re: DateTime column: why dictionary type is not "datetime (n
Hello, Vineet.
ADO.NET does not support nullable types.
Please, try to use the RegBusinessObject() method.
Thank you.
ADO.NET does not support nullable types.
Please, try to use the RegBusinessObject() method.
Thank you.