当我从页面的下拉列表中选择销售人员时,我想在管理面板中显示报告,但没有显示任何内容并在此处显示一些错误。
下面是我的代码:
protected void BtnViewReport_Click(object sender, EventArgs e)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/SalesPerson.rdlc");
DataSet ds = GetData("select * from customer_new where salesperson in (select +
email from Registration where name='" + ddsalesperson.SelectedValue.ToString() +
"')");
ReportDataSource datasource = new ReportDataSource("customer_new",ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
private DataSet GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
sda.Fill(ds, "customer_new");
return ds;
}
}
}
}
我收到以下错误:
尚未为数据源“DataSet1”提供数据源实例。