I've created a winform for users to see many reports for them. I have a drop down list with the report name, which triggers the appropriate field to display the parameters. After they are filled, they send the press and the report appears. It works on the screen for the first time. They can change the parameters and ReportViewer works fine. Convert to a different report, and I get the following ReportViewer error:
An error occurred during the local report processing. An error has occured during report processing. A data source example is not provided for data source "CgTempData_BusMaintenance"
As far as I use this process:
- I used the
ReportName
(string) The physical RDLC name is set. - I have set the
datasource
(string) as the datasource name - I fill a normal data cable with the data to run from the report .
- Make report viewer visible
-
Set up local report. Reportpath = "reports \\" = report name;
-
Local Reports. Clear data sources. ()
- Add new
LocalReport.DataSources.Add (New ReportDataSource (Data Source, DT));
-
Refresh Report () on ReportViewer
Here is the part of the code that sets up And displays report weaver:
/// & lt; Summary & gt; /// Creates a Report /// & lt; / Summary & gt; Private Zero BuildReport () {DataTable dt = null; Reporting CG RCG = New Reporting CG (); If (reportName == "GasUsedReport.rdlc") {dataSource = "CgTempData_FuelLog"; CgTempData.FuelLogDataTable DtFuelLog = rcg.BuildFuelUsedTable (to date, toDate); Dt = DtFuelLog; } Else if (reportName == "Inventory Cost. Rdlc") {CgTempData.InventoryUsedDataTable DtInventory; DataSource = "CgTempData_InventoryUsed"; DtInventory = rcg.BuildInventoryUsedTable (to date, toDate); DT = DT Inventory; } And if (reportName == "VehicleMasterList.rdlc") {dataSource = "CgTempData_VehicleMaster"; CgTempData.VehicleMasterDataTable DtVehicleMaster = rcg.BuildVehicleMasterTable (); DT = DTVHalmasters; } And if (reportName == "BusCosts.rdlc") {dataSource = "CgTempData_BusMaintenance"; Dt = rcg.BuildBusCostsTable (fromDate, toDate); } // Setup DataSource this.reportViewer1.Visible = true; This.reportViewer1.LocalReport.ReportPath = "Reports \\" + reportName; This.reportViewer1.LocalReport.DataSources.Clear (); This.reportViewer1.LocalReport.DataSources.Add (New ReportDataSource (Data Source, DT)); This.reportViewer1.RefreshReport (); }
Any idea how to remove the old balance data? Do I settle the object and recreate it?
I understand that I need to add: reportViewer1.Reset ();
In the beginning of the law.
Comments
Post a Comment