Page 1 of 1

Catching missing fields exception

Posted: Sat Nov 17, 2012 11:11 pm
by patwolf
We use one report on multiple related but not the same datasets.
Now I would like to show the user the names of the fields which are referenced in the report but are missing in the current dataset in a nice error message.

So I got this code to view a report.
try
{
DataSet ds = GetDs();
var report = new StiReport();
report.Load(fpn);
report.Render(false);
}
catch (Exception ex)
{
When a field is missing I get this error:
c:\Users\..\AppData\Local\Temp\a3zl2axx.0.cs(75,33) : error CS1061: 'Reports.Report.humanuserDataSource' does not contain a definition for 'sg_department' and no extension method 'sg_department' accepting a first argument of type 'Reports.Report.humanuserDataSource' could be found (are you missing a using directive or an assembly reference?)c:\Users\..\AppData\Local\Temp\a3zl2axx.0.cs(80,50) : error CS1061: 'Reports.Report.humanuserDataSource' does not contain a definition for 'sg_department' and no extension method 'sg_department' accepting a first argument of type 'Reports.Report.humanuserDataSource' could be found (are you missing a using directive or an assembly reference?)

Is there a better Exception I could catch to get just the missing field name(s) please?

Thanks
Patrick

Re: Catching missing fields exception

Posted: Mon Nov 19, 2012 11:03 am
by HighAley
Hello.

Unfortunately, there is no other exception.
You could parse the error message to get the missing field.

Thank you.