水晶报表引用DataSet做数据源
using CrystalDecisions.Shared ;
using CrystalDecisions.CrystalReports .Engine ;
。。。。。。
public class WebForm2 : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument1;
private void Page_Load(object sender, System.EventArgs e)
{
string strProvider = "Server=(local);DataBase=pubs;UID=sa;PWD=19";
SqlConnection MyConn = new SqlConnection(strProvider);
MyConn.Open();
string strSel = "Select * from employee where fname like 'P%'";
SqlDataAdapter MyAdapter = new SqlDataAdapter(strSel,MyConn);
DataSet1 ds = new DataSet1();//这个DataSet1在结构上最好跟水晶表的一致,
//路径可以不同
MyAdapter.Fill(ds,"employee) MyConn.Close();
reportDocument1.Load("d:\\Report2.rpt");
reportDocument1.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = reportDocument1;
CrystalReportViewer1.DataBind();
using CrystalDecisions.CrystalReports .Engine ;
。。。。。。
public class WebForm2 : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument1;
private void Page_Load(object sender, System.EventArgs e)
{
string strProvider = "Server=(local);DataBase=pubs;UID=sa;PWD=19";
SqlConnection MyConn = new SqlConnection(strProvider);
MyConn.Open();
string strSel = "Select * from employee where fname like 'P%'";
SqlDataAdapter MyAdapter = new SqlDataAdapter(strSel,MyConn);
DataSet1 ds = new DataSet1();//这个DataSet1在结构上最好跟水晶表的一致,
//路径可以不同
MyAdapter.Fill(ds,"employee) MyConn.Close();
reportDocument1.Load("d:\\Report2.rpt");
reportDocument1.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = reportDocument1;
CrystalReportViewer1.DataBind();
-----------------------------------------------------------------