This one gets me every time, so I’m going to write it up in hopes that next time I search for it, I’ll find my own solution.
Situation: You’ve created a datasource in your .Net app, and want to use it on your report (RDLC). You create the report, point to the new Dataset, drop on some fields and run the report. Your heart drops because you get the error message:
The type specified in the TypeName property of ObjectDataSource 'dsWhatever' could not be found.
Argh! How to solve this… you look at the source of a few other reports in XML to figure out what’s going on (Don’t forget to change that
What you have to do is simple, but infuriating. Before you invoke your report in your code behind file, you have to set the TypeName property of the report. You can do this either in the
String cXSD = "MyXSDFile"; // Name of your XSD file
String cDataSet = "MyDataSet"; // Name of your dataset within your XSD file
String cDataSource = cXSD+"_"+ cDataSet + "TableAdapter"; // eg. MyXSD_dsInvoiceTableAdapter
this.dsObject.TypeName = cXSD+ "TableAdapters." + cDataSet + "TableAdapter"; // eg MyXSDTableAdapters.dsInvoiceTableAdapter
this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource(cDataSource, this.dsObject));
Coming from a Visual Foxpro background, all of this seems like a huge PITA just to get some data to show on the screen. What do you think?
Leave a Reply