当前位置: 代码迷 >> ASP.NET >> ReportViewer 可以绑定dataset吗?一天了,救急呀!该怎么解决
  详细解决方案

ReportViewer 可以绑定dataset吗?一天了,救急呀!该怎么解决

热度:7382   发布时间:2013-02-26 00:00:00.0
ReportViewer 可以绑定dataset吗?一天了,救急呀!!!
1,我正常的把他绑定到dataset,就报错说xsd文件未定义.
2,我写的是存储过程,根据参数不同,得到不同的数据源.请贴点代码吧!谢谢!!!
先写个最简单的绑定dataset的吧!,然后写哪个带参的
  DataSet   tmpDs   =   new   DataSet();
  tmpDs   =   ReportOpts.GetProductReport(1,   "2007-01-01 ",   "2007-12-01 ",   -1,   -1,   -1,   0);
    rpvEx.ProcessingMode   =   crosoft.Reporting.WebForms.ProcessingMode.Local;
                    ReportDataSource   dsCustomers   =   new   ReportDataSource();

                        dsCustomers.Value   =   tmpDs.Tables[0].DefaultView;
                        localReport.DataSources.Add(dsCustomers);
                        localReport.Refresh();
不对啊!!!

------解决方案--------------------------------------------------------
sf
------解决方案--------------------------------------------------------
参考代码:

C# code 
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(); 



------解决方案--------------------------------------------------------
接分
  相关解决方案