Home » Visual Studio

Subreports and datasources

Hi, our current solution grabs a reports definition, modifies it to handle collapsable columns, modifies the reports datasource (else it blows up), then sends it back to the server for processing.  These modifications are done by doing string replaces. This has worked fine until now.  

The business has created reports with sub-reports.  The main report runs fine but where the sub-reports are to be displayed we get an error.  I've searched the net and the fix has been stated that when using web service calls to execute a report you need to use absolute datasource references vs relative.  This makes sense as that's why i modify the reports datasource above manually.  

Question 1:  Do i also need to load each sub-report, manually modify the definition to use absolute datasource references then send back to the server?  Is this best practice?

Question 2: Am i doing this all wrong?  Is there a better way of modifying a reports datasource than performing a string replace on the rdl file?

I'm thinking i've going about this the wrong way and hoping someone can "show me the light!"

Thanks for any help in advance!





4 Answers Found


Answer 1

Hi John,

SubReport has its own datasource. If the field that is the subreport's parameter associated is not changed, we don't need to modify  the subreport's datasource  referenece.
However, if the associated fields are changed, we need to modify the subreport's definition  even datasource reference.

If we just want to change the datasource reference, we can use the SetItemDataSources method to modify it.
Below is the sample code for your reference:

Dim reference AsNew DataSourceReference()
 reference.Reference = calalogItem.Path
 Dim source AsNew DataSource()
 source.Item = reference 
 source.Name = calalogItem.Name
 Dim sources As DataSource() = New DataSource(0) {}
 sources(0) = source
 rs.SetItemDataSources("report path", sources)

Anyway, in order to modify other elements, "string replace" is the right way.

If there is anything unclear, please feel free to ask.

Jin Chen


Answer 2

Thanks Jin, i'll give your code above a try.

Please do me a favor and confirm my overall understanding of datasources  when the report  is called using LoadReportDefinition followed by Render:

Our data source name for all reports  is called : reports.rds.  All of our reports (including sub-reports) reference that name.  We deploy that datasource  to a directory on the server  called DataSources/reports.rds.  All of our reports live on the server at Reports/<report name>.

- when i run a report I must modify  the reports datasource prior to calling Render as you've instructed above, so that the modified report points to an absolute  reference vs. a relative  path else the report will fail.  Meaning i have to change the reports datasource from reports.rds to DataSources/reports.rds.

- If the above report contains any sub-reports, i must also modify each sub-reports  datasource using the above code as well else each sub-report  will fail.

Are my statements true?

Thanks again for your help.  Have a great weekend.






Answer 3

I'm starting to pull my hair out on this one.   when i run the code below it errors out on the "SetItemDataSources" call.  

"The data source 'reportdatasource' cannot be found"


If i comment out the code below and simply do a string  replace it works:

strProductionReport.Replace("<DataSourceReference>" & Me.ReportDataSourceName & "</DataSourceReference>", "<DataSourceReference>" & Me.ReportDataSourcePath & "</DataSourceReference>")


Thoughts?  Doing a string replace  is not the way to do it.. and again.. i'll have to do it for every sub-report  as well.

Thanks, John


    Dim reportDataSources() As datasource  = _rsService.GetItemDataSources(Me.ReportUrl)
    If Not (reportDataSources Is Nothing) Then
      For Each ds As DataSource In reportDataSources
        Dim reference As New DataSourceReference
        reference.Reference = Me.ReportDataSourcePath
        Dim dss As New DataSource
        dss.Item = CType(reference, DataSourceReference)
        dss.Name = Me.ReportDataSourceName
        Dim dsList(0) As DataSource
        dsList(0) = dss
        dsList(0).Name = Me.ReportDataSourceName
        _rsService.SetItemDataSources(Me.ReportUrl, dsList)
      Next ds
    End If


Answer 4


if anyone has any ideas as to why the above code doesnt work please let me know.  Thanks!  john





I have one main report containing one subreport containing another subreport.

Invoices (Main report)

        Invoice (sub report)

                Details (sub report)

In the subreportprocessing event I pass a datatable to the details subreport. At runtime on every page of the report it displays only the details for the first invoice in the nested subreport. I stepped into code and the datatable seems to have the right data but the display is wrong. The code worked on Report Viewer 2008 and works with 2010 for the scenario with the Invoice as the main report and details the only sub report. It seems that if i nest more than 1 level of subreport things go wrong. Anyone has some ideeas?



I've got 2 folders:



In the Finance folder I have a Sales report that has 3 subreports, and a salesregion parameter.

I created a linked report in /Japan to /Finance/Sales, hide the salesregion parameter, and set the default to Japan, so they can only see their region's sales data.

But when a Japan user runs the Sales report, they get Error: Subreport could not be shown because they do not have access to the /Finance folder. Any ideas?


Visual Studio 2010 report designer:

How can we put the Plus sign off if there are no records available in the subreport? (This option is enabled by check marking "Display can be toggled by this report item" prompt at the Sub report properties dialog box.



iam really new to Crystal Report XI Release 2..iam using multiple subreport in mainreport and onclick of  particular subreport it would list out all items related to it..for example if u have customer chart(subreport) in mainreport and onclick of this it would list all customer on demand and subreport is binded and onclick of single customer it would list out single customer which sholud be passed as parameter it would get customer(full Contact details) in another subreport.if this can be done.please expalin briefly how it can be done and explain in steps how it can be and if possible with screen shots


iam new to crystal report..iam using multiple subreport in mainreport and onclick of  particular subreport it would list out all related to it..for example if u have customer chart(subreport) in mainreport and on click of this it would list all customer on demand and subreport is binded and onclick of single customer which should be passed as parameter and it would list out single customer full contact details in another subreport.if this can be done.please expalin briefly as step by step process how it can be done 


Hi All,

I have a report with 12 subreports (Jan to Dec)

The main report has employee column, other columns (i.e. Jan to Dec) which has some integers values specific to the employee.

The integer column is nothing but a subreport onclick of which we need to show the employee details for that month.

The subreport has two parameters (employeeid and month).

How should i pass parameters for subreport in the code.

Please help. Its urgent.



Anyone having issues with their object datasources appearing and
vanishing from the datasource browser?

I create an object for binding as a datasource in my App_Code folder,
compile my web project and it appears in the datasources in the report
designer.  Then I will make an aspx, setup a reportviewer control for
my new report, go back to the rdlc and the object datasource sometimes
just vanishes.

I refresh, no luck.

The only solution I found is to draft the rdlc to the App_Code folder
where my class is, then refresh datasources and it finds it.  Then if I
move it away, they vanish again.

Am I missing something on how the object datasources work in web



I am trying to use an XML datasource to implement a data-driven test in MSUnit. I am using Visual Studio 2010. It is unfortunate that the documentation for how to use this feature is very minimal. I have spent the past 2 hours scouring the Internet for resources and they have not been adequate yet.

The questions I am trying to figure out are:

When using an XML file, can I have a value in a row be XML data and not just a basic data type (int, string, ...)? How do I store an array of values for a specific value in a row? It seems that each row represents a test run and each element in a row stores a value. How to I set up one of those elements to be an array of values. In my case I want my XML to look like the following:

            <blobStart attrib1="value">
            <parameter name="param1" value="value1" />
            <parameter name="param2" value="value2" />
            <parameter name="param3" value="value3" />
            <parameter name="param4" value="value4" />
            <parameter name="param5" value="value5" />
            <parameter name="param6" value="value6" />
            something that should be correct




I am attempting to duplicate functionality in Microsoft Reporting I previously built into an application using crystal. I am building a generic report viewer in vs 2008 (c#) and am passing it the name of the report I want dispayed.

The reports are built on strongly typed datsets. I am having problems setting the datasource (which is not known at design time) and the connection string (also not known until runtime).

I can retrieve the datasource name using localreport.getdatasourcenames (which is not the same name as the dataset but I could parse that to get the data source name). However I can't use that to build a generic data adapter (or can I).

I have it working for a single report where I excplicity define the typed dataset and tableadapter. I think I have to access the datasource table adapter (data sources were created in vs) fill command.

Ideally I would just set the connectionstring of the localreport datasource but that is not an option.

This must be a common situation. How can I dynamically create a dataset at runtime based on the report definition?

Any advice would be appreciated.


We have a couple of Report servers and are in the process of chaging Domains and some Machines. What I need to do is verify the shared datasources on all of the servers.

Does anyone have a section of code (C#, Powershell, or TSQL) that would export the Datasource configuration to a flat file so that we can look at the data.


I have a report that has a list.  I use the list to define the report header and group by each location (page break after each location).

I need to have 2 matrices, each with a different datasource.  The first matrix has the same datasource as the list and that one works fine.  The second matrix has a different datasource and I cannot select fields from that datasource, the fields are not available.

If it weren't for the grouping by Location I wouldn't need the list and I could just have the 2 matrices, but I need to have the report be by Location and break when it encounters a new location.

How do I go about doing this?



Hi All,

I'm trying to learn how to enable \ disable SampleData such that when the real data is being worked on, I can revert to the Sample data. I want to be able to Enable \ Disable SampleData such that I can design with it and when the application is run, that it uses the Sample data.

I started with a DataGrid, added a SampleDataSource that contained the fields I was after and then

1. Alt + dragged the SampleData source to the window Grid.

2. Created an Observable Collection Class that I then dragged onto the Grid also.

This is what it looks like:

  <local:BuildSizeRoster x:Key="BuildSizeRosterDataSource" d:IsDataSource="True"/>
 <Grid d:DataContext="{Binding Source={StaticResource SampleDataSource}}" DataContext="{Binding Source={StaticResource BuildSizeRosterDataSource}}">

So to the best of my understanding I now have something that says ... if in design mode, use SampleDataSource, else use this BuildSizeRosterDataSource.

The logic seems to be based more on - when in Expression show this, when running show this. Is there a simple way to switch between the DataSources in both Expression and when the application is run.




I want to Implement Business Intelligence by SharePoint 2010 on top of data sources other than MS SQL Server or MS Analytics Services ( cubes ), for example Oracle RDBMS and Oracle OLAP ( cube ) or Teradata.

Quesiton :

Is there any way to do this, if the is, how do I bring metadata to sharepoint BI or how do I make SharePoint BI to see other data source. I've looked at Busines Data Connectivity in Visual Studio, but that is more for two way integration and didn't seem like a good or easy way just to bring new data sources to SharePoint BI

I found some tool from third party company "BDC Meta Man" which created metadata layer for Oracle RDBMS in SharePoint, but I thought there must be a way to do it by using Microsoft tools


I'm new to ASP.net and I'm developing my first web site.  I have a question about using datasources.  MS Supports multiple different data sources in ASP.net 3.5 when working with a SQL Server Data Layer.  Which data source do you use and how would you compare them with respect to (a)  Development Time,  (b)  Processing Speed, and (c) Supportability.

    SQL DataSource

    Object DataSource

   Linq DataSource

   Database DataSource

   Entity DataSource

For example I understand that the Linq DataSource is slow especially if you use it to display lookup data in noneditable fields in a Gridview.    


In your development activity, do you always use one or another? Or are the some situations where one is better than another?  For example, would you use one in Gridviews and another in FormViews?


Thanks for your help










Visual Studio 2010 (with ReSharper). Desktop application in C#.

I added several datasources to my forms project and they're visible under the project's Properties\DataSources node in the Solution Explorer window.

I want to move all the items in this project to a sub folder of another project.

I can select the source DataSources folder and the context menu offers all the usual cut/copy options, but when I select the target Properties folder, the context menu doesn't offer paste.

Is there an easy way to copy my datasources across, or do I need to recreate them all?

(I mention I run ReSharper as a tool in Visual Studio because I'm not sure which of them generate this subfolder)


I have a listObject called "Factors" created during design time on an EXCEL Worksheet and I would like to bind "Factors" to a DataGridView.

The easiest way would be, I suppose, to add it using the Menu Data > Add Datasource but "Factors" does not seem to be kown by DataSources.

What can I do?



I am not sure if this is the right  forum, so let me know if I need to post elsewhere.

I am developing a standard ASMX web service for use with WPF/Silverlight applications (as well as other apps).  

However, when I create a new .NET 4 WPF or Silverlight application and add a service reference to my ASMX (not SVC), it lists all of the methods in the datasource pane fine, but when I try to show the contents, I get an error:

Could not load file or assembly 'System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.  The system cannot find the file specified.

Is there something in the service configuration that I need to do, or is there something wrong with my web service?   In .NET 3.5 I do not get an error, but it doesn't show me the contents of the data sources either.  

Anyone have any ideas?



In WPF, when I connect to an ASMX web service that I built, my DataSources pane shows all of the return objects and I can drill down on them and see the contents so that I can bind to my controls.

However, when I create the same service reference in a Silverlight 4.0 using .NET 4.0, the datasources pane only shows the return objects and I cannot drill into them to see their contents.

Am I doing something wrong or is there some difference in the way WPF and Silverlight handle ASMX web services?



I am using a silverlight .xaml.  It is a dial gauge that can point to a number based on its value.  I want to retreive this number from a datasource and I'm not sure how to do this.  The number will change every time it is requested.  The datasource could be SQL Server, DB2 or Oracle.

Is this done via the .xaml.cs?  The .xap will be on an .ascx web user control in my asp.net web application, displayed as a widget.

I dont want to hard code the connection string - it will be in the web.config but I have read you cannot take read the web.config using .xaml?

 What would the best way to go about this be?


hello! forums

Please tell me how to create xcelsius reports from datasources like odbc for .net applications?




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure