How to create a reportvariable "datetime (nullable)" by code

Stimulsoft Reports.NET discussion
Post Reply
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to create a reportvariable "datetime (nullable)" by code

Post by Fabio Pagano »

I need to create a reportvariable "datetime (nullable)" by code.

I try this:

Code: Select all

Dim v As New Stimulsoft.Report.Dictionary.StiVariable
v.Name = "MyName"
v.Alias = v.Name
v.Type = CType(GetType(Date), Type)
v.ReadOnly = False
v.Category = rv.Category
report.Dictionary.Variables.Add(v)
Note this line:

"v.Type = CType(GetType(Date), Type)"

The resulting reportvariable type is "DateTime", not "DateTime (nullable)" so if i pass a value of nothing the date is converted in today's date, if a pass a "date" variable (not assigned to any value) is converted in "01/01/0001". If i manually change the reportvariable type in "Datetime (nullable)" the field is left blank (that was i want).

So, how can i create by code a "DateTime (nullable)" reportvariable?

Or, alternatively, how can i print an empty field when i pass a value of "Nothing" to a "datetime" report variable?

Thanks.
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

How to create a reportvariable "datetime (nullable)" by code

Post by Brendan »

Try using this line:

Code: Select all

v.Type = CType(GetType(Nullable(Of Date)), Type)
Regards,
Brendan
Post Reply