Page 1 of 2

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Thu Sep 13, 2007 8:21 am
by Fabio Pagano
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.

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Fri Sep 14, 2007 4:39 am
by Guest
Unfortunately, we can't resolve this issue, because we use the types of ADO.NET and it haven't datetime(nullable) type.

Thank you.

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Fri Sep 14, 2007 5:00 am
by Fabio Pagano
This means that i can't print an empty field when the date is null? Is there any workaround you can suggest?

Thanks.

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Fri Sep 14, 2007 7:53 am
by Fabio Pagano
Unfortunately, we can't resolve this issue, because we use the types of ADO.NET and it haven't datetime(nullable) type.
But in designer i see type "datetime (nullable)" in the column:

Image

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

Posted: Sat Sep 15, 2007 3:05 pm
by Brendan
What happens when you try this piece of code in your application?

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()
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.

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Sat Sep 15, 2007 5:41 pm
by Fabio Pagano
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:

Code: Select all

Dim report As New Stimulsoft.Report.StiReport()
        report.RegData("MyData", tableDate)
        report.Design()
add the following line after report variable declaration:

Code: Select all

report.ScriptLanguage = Stimulsoft.Report.StiReportLanguageType.VB
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.

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Sat Sep 15, 2007 6:57 pm
by Brendan
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.

DateTime column: why dictionary type is not "datetime (nullable)"?

Posted: Sat Sep 15, 2007 8:33 pm
by Fabio Pagano
That makes sense to all, and works.

Thanks to all.

Re: DateTime column: why dictionary type is not "datetime (n

Posted: Wed Nov 29, 2017 3:51 am
by vineet
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

Re: DateTime column: why dictionary type is not "datetime (n

Posted: Fri Dec 01, 2017 2:53 pm
by HighAley
Hello, Vineet.

ADO.NET does not support nullable types.
Please, try to use the RegBusinessObject() method.

Thank you.