C# asp.net中的rdlc报告存在问题

C# asp.net中的rdlc报告存在问题,c#,sql-server,reportviewer,C#,Sql Server,Reportviewer,问题:无法在Reportviewer中绑定报表。我在“dtnew”中获得记录,但无法在我的应用程序中看到报告 获取报告中的错误“尚未为数据源'dsInOutReport\u InOut'提供数据源实例”添加以下内容: private void btnGenerate_Click(object sender, EventArgs e) { try { if (Convert.ToDateTime(da

问题:无法在Reportviewer中绑定报表。我在“dtnew”中获得记录,但无法在我的应用程序中看到报告

获取报告中的错误“尚未为数据源'dsInOutReport\u InOut'提供数据源实例”

添加以下内容:

 private void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToDateTime(dateTimeTo.Text).Date >= Convert.ToDateTime(dateTimeFrom.Text).Date)
                {
                    DateTime today = DateTime.Today.Date;
                    reportViewer1.RefreshReport();
                    reportViewer1.LocalReport.Refresh();
                    DataTable dtnew = new DataTable();
                    string EmpId = null;

                    if (ddlEmployee.SelectedIndex > 0)
                    {
                        EmpId = ddlEmployee.SelectedValue.ToString();
                    }

                    reportViewer1.LocalReport.DataSources.Clear();
                    dtnew = new dbInOutTimeDatasetTableAdapters.InOutTableAdapter().GetData(Convert.ToDateTime(dateTimeTo.Text), Convert.ToDateTime(dateTimeFrom.Text),new Guid(EmpId));
                    //   dtnew = new dsReportTableAdapters.ReportTableAdapter().GetData(Convert.ToDateTime(dateTimeFrom.Text), Convert.ToDateTime(dateTimeTo.Text), EmpId, DeptId);

                    reportViewer1.Visible = true;
                    ReportDataSource rptds = new ReportDataSource("dbInOutTimeDataset_ReportInOut", dtnew);
                    reportViewer1.LocalReport.DataSources.Add(rptds);
                    reportViewer1.LocalReport.Refresh();
                    reportViewer1.RefreshReport();
                    reportViewer1.Visible = true;
                }
                else
                {
                    MessageBox.Show("To date must be greater or equal to From date.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
            catch (InvalidOperationException exI)
            {
                MessageBox.Show("There is no any Employee Absent.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unhandled Error:" + ex.Message);
            }
        }
在此之前:

reportViewer1.LocalReport.DataSources.clear();

这将起作用。

问题是否在于您在报告文件中使用的数据源名称(“dsInOutReport\u InOut”)与代码中的名称(“dbInOutTimeDataset\u ReportInOut”)不同?
reportViewer1.LocalReport.DataSources.Add(rptds);