Friday, February 17, 2012

dbnull

Is there an easy way in Reporting service to handle dbull in dataset?

I am using the local mode of the new reportviewer control, when I feed the dataset to the report, if there are some dbull column, an exception will be thrown.

To those string column, I can set NULLVALUE property to empty, but to other datatype, like integer, datetime, money, what should I do?

ThanksDBNull is translated to a unitialized object in the report. You can use IsNothing, i.e. IsNothing(Fields!Foo.Value).|||Hey, you know what, it is very strange.

If I use BindingDatasource.datasource = ds.tables(0), (BindDatasource is bound to ReportViewer), I will have exception if any field is null.

But if I use
BindingDatasource.datasource = ds
BindingDatasource.datamember = "Table1"

I don't get exception any more.

Don't why, but it works like charm.

Wei|||

If this solves your problem, please mark the question answered. Thanks. :)

|||In addition to =IsNothing(Fields!Foo.Value), you could use the IS keyword: (Fields!Foo.Value is Nothing)

-- Robert

No comments:

Post a Comment