先建数据源,这样得到datatable.
再建报表,datasource就用刚才的datatable,在表格或图中选择对应的数据.
建网页,插入reportviewer,选择显示的报表.在网页代码中从库中查数据得到dataset,
ReportDataSource rds2 = new ReportDataSource("DataSet1", ds2.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(rds2);
ReportViewer1.LocalReport.Refresh();
注意"DataSet1"要和报表中的数据源名字相同.
建立数据源只是告诉报表有那些字段可用,真正的数据是运行时赋给他的,注意字段名要匹配.
温馨提示:答案为网友推荐,仅供参考