我正在尝试创建 rdlc 报告,但在尝试执行程序时遇到错误
错误:“”=在设置 DataSource 属性时无法修改 Items 集合。
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, "whbal");
cboFrom.DataBindings.Clear();
cboTo.DataBindings.Clear();
cboFrom.Items.Add(ds.Tables["whbal"]);
cboFrom.DataSource = ds.Tables["whbal"];
cboFrom.DisplayMember = "customer";
cboFrom.ValueMember = "customer";
myconnection.Close();
reportViewer1.Reset();
reportViewer1.LocalReport.DataSources.Clear();
LocalReport report = new LocalReport();
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", customerBindingSource));
report.ReportPath = "Report1.rdlc";
reportViewer1.LocalReport.Refresh();
}
如果我错过了什么,任何人都可以评论和帮助吗?提前致谢