Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未显示RDLC报告_C#_.net_Rdlc - Fatal编程技术网

C# 未显示RDLC报告

C# 未显示RDLC报告,c#,.net,rdlc,C#,.net,Rdlc,我在一个表单中完成了按钮和报表查看器。但是,我的报告没有显示,也没有数据 private void btnGenerate_Click(object sender, EventArgs e) { string connectionstring = "MultipleActiveResultSets=True;Data Source=ECSTSRD;Initial Catalog=SSWSQL;User ID=sswuser;Password=sswuser123"; SqlCon

我在一个表单中完成了按钮和报表查看器。但是,我的报告没有显示,也没有数据

private void btnGenerate_Click(object sender, EventArgs e)
{
    string connectionstring = "MultipleActiveResultSets=True;Data Source=ECSTSRD;Initial Catalog=SSWSQL;User ID=sswuser;Password=sswuser123";
    SqlConnection myconnection = new SqlConnection(connectionstring);

    myconnection.Open();

    string sql = "SELECT customer, imp_license_no, psq_level FROM customer WHERE customer= @cust1";

    SqlCommand custcom = new SqlCommand(sql, myconnection);

    custcom.Parameters.AddWithValue("@cust1", cboFrom.SelectedValue.ToString());

    SqlDataAdapter da = new SqlDataAdapter(custcom);
    DataSet1 ds = new DataSet1();
    da.Fill(ds, "customer");

    cboFrom.DataSource = ds.Tables["customer"];
    cboFrom.DisplayMember = "customer";
    cboFrom.ValueMember = "customer";

    myconnection.Close();

    LocalReport report = new LocalReport();

    reportViewer1.Reset();
    reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
    reportViewer1.LocalReport.DataSources.Clear();
    reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", customerBindingSource));
    reportViewer1.LocalReport.Refresh();
}

匆匆看了一眼,我怀疑这与此有关

reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", customerBindingSource));
我在您的代码中没有看到
customerBindingSource
。它可能应该引用datatable
ds.Tables[“customer”]


您应该确保rdlc文件中的设计与我更改为ds后显示的数据集设计类似。:报表数据源对象的类型必须为System.data.DataTable、System.Collections.IEnumerable、System.Windows.Forms.BindingSource或System.type。你对此有什么想法吗?对不起,我忘了数据表。好的,请尝试ds.Tables[“customer”],因为它是您填写数据的customer表。请在回答中突出显示您所做的更改以及更改的原因。
    1-reportViewer1.Reset();
    2-reportViewer1.LocalReport.DataSources.Clear();
    3-reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
    4-reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", customerBindingSource));
    5-reportViewer1.LocalReport.Refresh();
    6- reportViewer1.RefreshReport();