I am automatically creating a PDF from some of our reports in a month-end process. I am running into a problem where ReportViewer.LocalReport
can't find my report. Within the project, the report files are in "(project root folder)/Reports/report.rdlc".
How do I set ReportViewer.LocalReport.ReportPath
so I can reference my report file?
I would rather not set the full path because I don't know where it would be installed when installed on the client machines.
The RDLC Report in in Windows Forms (WinForms) application will be populated using Typed DataSet. In this article I will explain a simple tutorial with an example and sample code to create RDLC Report in Windows Forms (WinForms) application using C# and VB.Net.
Step 1: Create a new project name as “ Dynamic RDLC Report ” and press button “ OK ”. Step 2: Drag and drop the one textbox, button and report viewer, and label from toolbox and set the label name “ Employee ID ”. And add the Oledb connection. Step 3: After that we can create a database in Microsoft Access 2013.
Using the WinForms ReportViewer Control. To view reports that have been deployed to a report server or reports that exist on the local file system, you can use the WinForms ReportViewer control to render them in a Windows application.
You will need to click on the small arrow present on the top right corner of the Report Viewer and choose the RDLC Report as shown below. 10. Populating the RDLC Report from Database
Use the Application.StartupPath property, it always points to directory where your EXE is located:
using System.IO;
...
string exeFolder = Application.StartupPath;
string reportPath = Path.Combine(exeFolder, @"Reports\report.rdlc");
You'll want to make sure the report gets copied to your bin\Debug\Reports folder as well so it will work in the IDE. Use xcopy /s /d in a post-build event to get the file(s) copied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With