Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RDLC - Adding a Data Source in VS2010

Greetings.

I have an RDLC file and am wanting to add a data source to it, although without any luck so far. The data source is a custom class written by myself (just to add, we do this all the time). We recently converted over to the VS2010 RDLC format which caused some problems, but we've made some changes to our implementation that workaround the more major issues.

So, back to the issue at hand, when I attempt to add my data source to the DummyDataSource list in the RDLC view in VS2010 it just does nothing, however it does add the data source to the list of data sources, but you can't select it from the drop-down list in the RDLC view which means I can't add the data source at all.

Has anyone come across this problem? Is there anything I need to check? I've searched with fervour and had no luck.

like image 636
Kezzer Avatar asked Dec 29 '10 12:12

Kezzer


People also ask

How do I add a dataset to an existing Rdlc report?

Give Application name--RDLC and Click OK. Right click on Application select Add, and again select New Item. Select dataset and give dataset name (Student Order) and click Add button.

How do you add a data source?

To create a dataset as a data source, run the Data Source Configuration Wizard by selecting Project > Add New Data Source. Choose the Database data-source type, and follow the prompts to specify either a new or existing database connection, or a database file.

How do I add a DataSource in Visual Studio?

Open your project in Visual Studio, and then choose Project > Add New Data Source to start the Data Source Configuration Wizard. Choose the type of data source to which you'll be connecting. Choose DataSet from the list of options. Choose the database or databases that will be the data source for your dataset.


2 Answers

There seems to be a bit of black magic going on here. Or at least I haven't figured out all of the incantation to make this happen reliably.

I think I was having a similar problem. Not sure if this will help you, but here's how I got around it.

In the VS2010 report designer, use view->Report Data to show the Report Data pane.

Click the New button and choose Dataset... to get the Dataset Properties dialog.

Name your Dataset, if you've done this before, you probably know that the dataset name here needs to match the name provided in code when you bind your ReportDataSource.

The new part that I just tried, is to click the New... button next to the Data source drop down list. The resulting wizard walks you through selecting your assembly and CLR class (use the checkbox to select your class).

When the wizard finished, my new dataset appeared.

One thing to note: The first time I tried to reproduce this, the wizard completed without adding my dataset. I went back to my class definition and decorated it with [DataContract] and [DataMember] attributes and then re-ran the wizard and it seemed to work great.

Perhaps someone with deeper knowledge can comment on why those attributes make this work, or why the wizard fails silently without them.

like image 64
Paul Chavez Avatar answered Oct 11 '22 03:10

Paul Chavez


Your data source object must include a native data type as a property on the class, otherwise it doesn't let you add it. Funny, eh!

like image 42
Kezzer Avatar answered Oct 11 '22 01:10

Kezzer