Hi,
for several reports, I need to discern if a given field equals null or 0.
I have the ConvertNulls-property of the report set to false.
In the Databand.Beforeprint event, I have tried this
if (!Datenquelle1.STMAPROZENT.Equals(null))
and this
if (Datenquelle1.STMAPROZENT != null)
Both versions compile all rigth, but I get the following error at runtime:
Method: [get_STMAPROZENT]
Die angegebene Umwandlung ist ungültig.
this should roughly translate to: this conversion is invalid.
So, what am I doing wrong?
Null values
Null values
Please use the following expression for checking for the null values (in the onGetValue event handler for example):
ConvertNulls property should be set to false.
Thank you.
Code: Select all
if (Datenquelle1["STMAPROZENT"] == null)e.Value = "YES";
else e.Value = "NO";
Thank you.
Null values
Ok, I tried this, and now I have the following code in Databand1.BeforePrint:
If I edit my SQL-Statement to include only datarows where STMAPROZENT is not null, this works all right. If I only include datarows where STMAPROZENT is null, it still always goes into the else branch. Then, the line
results in the error message that I have posted before.
So it seems that null values are not recognized as such.
Am I still doing something wrong? Do I have to use another event for this?
Code: Select all
double wgt;
if (Datenquelle1["STMAPROZENT"] == null)
{
MessageBox.Show("null");
wgt = 1;
}
else
{
MessageBox.Show("not null");
wgt = Datenquelle1.STMAPROZENT/100;
}
Code: Select all
wgt = Datenquelle1.STMAPROZENT/100;
So it seems that null values are not recognized as such.
Am I still doing something wrong? Do I have to use another event for this?
Null values
Please check following code:
Thank you.
Code: Select all
if (Datenquelle1["STMAPROZENT"] == null || Datenquelle1["STMAPROZENT"] == DBNull.Value))
Null values
All right, it works now.
Thanks a lot, great service!
Thanks a lot, great service!