C# Microsoft报表查看器不生成报表

C# Microsoft报表查看器不生成报表,c#,mysql,.net,report,dynamic-rdlc-generation,C#,Mysql,.net,Report,Dynamic Rdlc Generation,我正在用MySql数据库在C.NET中创建应用程序。我正在创建一个报告,我的数据库中有一个invoice_details表,它是用MySql创建的 我想打印Sr.No。当我的报告被打印时。因此,我正在我的页面加载事件中编写下面的代码 至少我用这段代码完成了所有步骤。我已经设计了包含上述列的报告文件及其数据集。我还通过对话框将数据源添加到rdlc报告文件,并将rdlc文件添加到MicrosoftReportViewer 现在的问题是-它将编译所有步骤和代码行,并且没有错误,但它仍然不会生成报告,只

我正在用MySql数据库在C.NET中创建应用程序。我正在创建一个报告,我的数据库中有一个invoice_details表,它是用MySql创建的

我想打印Sr.No。当我的报告被打印时。因此,我正在我的页面加载事件中编写下面的代码

至少我用这段代码完成了所有步骤。我已经设计了包含上述列的报告文件及其数据集。我还通过对话框将数据源添加到rdlc报告文件,并将rdlc文件添加到MicrosoftReportViewer

现在的问题是-它将编译所有步骤和代码行,并且没有错误,但它仍然不会生成报告,只是默认退出

我在下面发布frmReport.cs文件代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
using Microsoft.Reporting.WinForms;
using System.IO;


namespace CeraAccount.Modules
{
    public partial class frmReportViewer : Form
    {
        public int INVOICE_NO;

        public frmReportViewer()
        {
            InitializeComponent();
        }

        private void frmReportViewer_Load(object sender, EventArgs e)
        {            
            MySqlConnection conn;
            MySqlCommand cmd;
            MySqlDataReader dr;
            //Report data source object define here
            invoiceReportDataSource objDataSet = new invoiceReportDataSource();

            try
            {
                conn = new MySqlConnection(Program.ConnectionString);
                conn.Open();
                cmd = new MySqlCommand();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT * FROM invoice_details";
                dr = cmd.ExecuteReader();
                int i = 1;
                //Get selected record in seperate table object

                while (dr.Read())
                {
                    DataRow row = objDataSet.Tables["invoice_details"].NewRow();
                    row[0] = Convert.ToInt32(dr["id"].ToString());
                    row[1] = dr["invoice_no"].ToString();
                    row[2] = dr["description_of_goods"].ToString();
                    row[3] = dr["size"].ToString();
                    row[4] = dr["grade"].ToString();
                    row[5] = dr["quantity"].ToString();
                    row[6] = dr["max_retail_price"].ToString();
                    row[7] = dr["ass_rate_per_unit"].ToString();
                    row[8] = dr["total_ass_value"].ToString();
                    row[9] = dr["sale_price_per_unit"].ToString();
                    row[10] = dr["total_sale_value"].ToString();
                    row[11] = dr["created"].ToString();
                    row[12] = i;
                    objDataSet.Tables["invoice_details"].Rows.Add(row);
                    i++;
                }
                conn.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            ReportDataSource rds = new ReportDataSource("objDataSet", objDataSet.Tables["invoice_Details"]);
            this.rptViewer.LocalReport.EnableExternalImages = true;
            this.rptViewer.LocalReport.EnableHyperlinks = true;
            rptViewer.LocalReport.DataSources.Clear();
            rptViewer.LocalReport.DataSources.Add(rds);
            this.rptViewer.RefreshReport();
        }

    }
}

伙计们,我们在一个报表文件中添加了多少个报表参数?

您实际在哪里将数据绑定到rptViewer,例如rptViewer.DataBind;应该在RefreshReport方法之前调用。您是否熟悉如何使用调试器?是的,我也熟悉调试器逐行代码,但当我按F10进行逐行调试时,它不会生成异常,只需执行步骤。和rptViewer.DataBind;rptViewer是否需要使用方法?