Hi @Roberto C , Welcome to Microsoft Q&A,
You can try using the following code to load the dataset and associate it to the report:
using System;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
namespaceCapaPresentacion
{
public partial class Informes : Form
{
publicInformes()
{
InitializeComponent();
}
private void Informes_Load(object sender, EventArgs e)
{
//Create dataset object
DataSetInformes dataSet = new DataSetInformes();
try
{
// populate the data set
this.grupoTableAdapter.Fill(dataSet.Grupo);
//Set report path
this.reportViewer1.LocalReport.ReportPath = "TicketUltimaVenta.rdlc";
//Create report data source
ReportDataSource reportDataSource = new ReportDataSource("DataSetInformes", dataSet.Tables["Grupo"]);
// Clear and add report data source
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
// refresh report
this.reportViewer1.RefreshReport();
}
catch (Exception ex)
{
MessageBox.Show("Error loading report: " + ex.Message);
}
}
}
}
Make sure to add this code to the Load event of the Informes form and associate it with the ReportViewer control.
Make sure to replace "DataSetInformes" and "Grupo" in your code with the actual names of your datasets and data tables.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.