如何在水晶报表中动态显示数据?使用PUSH方法,急!!!
现在想实现如下功能:
使用northwind数据库,想让水晶报表显示的数据为查询得到的数据,即动态给水晶报表设置一个数据源,主要代码如下:
SqlConnection mConn = new SqlConnection("user id=sa;password=;initial catalog=northwind;data source=localhost");
SqlDataAdapter mAda = new SqlDataAdapter("select * from products where productid=1",mConn);
DataSet mDs = new DataSet();
mAda.Fill(mDs);
ReportDocument crReport = new ReportDocument();
string strPath=@"c:\inetpub\wwwroot\demo_dynamic_report\CrystalReport1.rpt";
crReport.Load(strPath);
crReport.SetDataSource(mDs);
CrystalReportViewer1.ReportSource = crReport;
CrystalReportViewer1.DataBind();
但是这样显示出来的还是全部product信息,请问诸位高手能不能指点迷津。
问题解决了立刻结帖~谢谢!