日期:2014-05-18 浏览次数:20423 次
SqlParameter[] conditionParameter = new SqlParameter[] { new SqlParameter("@Year",ddlYear.SelectedValue) }; ReportParameter[] param = new ReportParameter[] { new ReportParameter("ReportParameterYear", ddlYears.SelectedItem.Text.ToString()), }; //Get Data into dataset string thisConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection thisConnection = new SqlConnection(thisConnectionString); DataSet thisDataSet = new DataSet(); thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "uspXXX", conditionParameter); ReportDataSource datasource = new ReportDataSource("dsxxx_uspxxx", thisDataSet.Tables[0]); //Displayed in ReportVierer ReportViewer1.Visible = true; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); if (thisDataSet.Tables[0].Rows.Count == 0) { lblMessage.Text = "xxxx!"; } else { lblMessage.Text = String.Empty; } ReportViewer1.LocalReport.SetParameters(param); ReportViewer1.LocalReport.Refresh(); }
------解决方案--------------------
先转换好了再给数据源啊