Page 1 of 1

Null values

Posted: Wed Dec 06, 2006 9:26 am
by ikirck
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

Posted: Wed Dec 06, 2006 10:04 am
by Edward
Please use the following expression for checking for the null values (in the onGetValue event handler for example):

Code: Select all

if (Datenquelle1["STMAPROZENT"] == null)e.Value = "YES";
	else e.Value = "NO";
ConvertNulls property should be set to false.

Thank you.


Null values

Posted: Thu Dec 07, 2006 3:28 am
by ikirck
Ok, I tried this, and now I have the following code in Databand1.BeforePrint:

Code: Select all

double wgt;

if (Datenquelle1["STMAPROZENT"] == null)
{
    MessageBox.Show("null");
    wgt = 1;
}
else
{
    MessageBox.Show("not null");
    wgt = Datenquelle1.STMAPROZENT/100;
}
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

Code: Select all

wgt = Datenquelle1.STMAPROZENT/100;
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?

Null values

Posted: Thu Dec 07, 2006 3:54 am
by Vital
Please check following code:

Code: Select all

if (Datenquelle1["STMAPROZENT"] == null || Datenquelle1["STMAPROZENT"] == DBNull.Value))
Thank you.

Null values

Posted: Thu Dec 07, 2006 4:09 am
by ikirck
All right, it works now.

Thanks a lot, great service!