F
F
FaNaT2020-03-12 18:45:24
C++ / C#
FaNaT, 2020-03-12 18:45:24

How to populate reportViewer C# programmatically?

Hello. There is a database created in access.
The form has a completely empty reportviewer. I want to fill it programmatically, not through the constructor.

I'm trying to do this:

OleDbDataAdapter dataAdapter = new OleDbDataAdapter("Select * FROM Orders", Connect.con);
                DataSet ds = new DataSet();
                dataAdapter.Fill(ds);
                reportViewer1.Reset();
                this.reportViewer1.LocalReport.DataSources.Clear();
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Value = ds.Tables[0];
                reportDataSource.Name = "DataSetAssetList";
                this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
                this.reportViewer1.LocalReport.ReportEmbeddedResource = "AssestsManagementSystem.ReportAssetList.rdlc";
                this.reportViewer1.RefreshReport();


But on the form I get the following message:
An error occurred while processing the report locally.
The ReportAssetList report has no definition.
An object reference does not point to an instance of an object.


I tried a variety of options, but there is no effect. It is either completely empty, without anything at all, or with such messages.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question