Hello i'm cuban and i'm doing an aplication in Visual Studio 2005. I have a problem with this code because i have an error. I want dinamically load differents reports in one page usin the reportviewer control. This is my code. please help me and tell me what's wrong here. This code i'ts for a testProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.ReportViewer1.ProcessingMode = ProcessingMode.Local Me.ReportViewer1.LocalReport.ReportPath = "C:\Inetpub\wwwroot\pepe1\report1.rdlc" Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("clientes", cargar())) Me.ReportViewer1.LocalReport.Refresh() End Sub Function cargar() As Data.DataSet Dim con As New SqlConnection("Data Source=(local);Initial Catalog=contenedores;Persist Security Info=True;User ID=sa") Dim tabla As New Data.DataSet Dim adapter As New SqlDataAdapter("select * from clientes", con)
adapter.Fill(tabla)Return tabla End Function
when i load my page this i'ts the error on the page:
- A data source instance has not been supplied for the data source 'DataSet1_Clientes'.
If i put an Objectdatasource in my webform, this dont happen and it works good, but i want to use many reportrts (*.rdlc) files with the same webform and including parameters too. Please if you have some examples please send my this (even in C# dont matter). thanks for everething.
I'm sorry for my bad english jajajajaja. byeplease answer me to this email firstname.lastname@example.org
Open report1.rdlc into Visual Studio 2005 and Click Report Menu - Data source. Find How many datasources are there. If you find 2 datasources then
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1_Clientes", cargar()))
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet2_Clientes", cargar()))
assign like this.
It will work.
- Proposed as answer by Reveles Wednesday, May 13, 2009 11:16 PM
The Answer is in this method ... Reset () ... you must reset the report viewer befor changing the data source .... a typical working code may look like this :
ReportViewer1.Reset(); ReportViewer1.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource("DataSet_DataTable1",ObjectDataSource1); ds.DataSourceId = "ObjectDataSource1"; ReportViewer1.LocalReport.DataSources.Add(ds); ReportViewer1.LocalReport.ReportPath = "NewReportToView.rdlc"; ReportViewer1.LocalReport.Refresh();
Best regards ... please mark it as the answer if you find it usefull ... :) ^_^
I know this is an old thread, but let me give a few more pointers since it shows up early on in the search.
First, I have to define the report (IssueView.rdlc) with a dataset, then bind columns and such to dataset elements. However, that dataset (actually a view defined in my SQL Server database) is relatively worthless in display terms. However, it does contain the fields I need to show. So I create a DataSet which contains the actual values. A few things to note:
1. The field names in the DataSet must correspond exactly to field names in the original view.
2. The name of the dataset in the ReportDataSet object must be exactly the same as the name of the dataset specified when I created the report. The following code works:
DataSet ds = new DataSet();
object oData = new object[ds.Tables["A"].Columns.Count];
foreach (var ql in qLog)
oData = ql.ID;
oData = ql.DateCreated;
oData = ql.DCNOld;
oData = ql.UserID;
oData = ql.BusinessUnit;
oData = ql.FKIssueID; // In the production version there is code to turn this into a list of descriptions, which in WPF is handled by a value converter.
this.viewerInstance.LocalReport.ReportEmbeddedResource = "IssueTracker.IssueView.rdlc";
ReportDataSource rds = new ReportDataSource();
rds.Value = ds.Tables[