设置dataset。xsd
SqlConnection con = new SqlConnection("server=(local);database=ddl;uid=sa;pwd=;");
string sel = "select * from ddl2 where father='1'";
SqlDataAdapter sda = new SqlDataAdapter(sel, con);
con.Open();
// DataSet1 ds = new DataSet1();
DataSet ds = new DataSet();
sda.Fill(ds);
CrystalReportSource1.ReportDocument.Load(Server.MapPath("ee.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables[0]);
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
报表select id,name,father from ddl2 where father='{?fath}'
CrystalReportSource1.ReportDocument.Load(Server.MapPath("dd.rpt"));
CrystalReportSource1.ReportDocument.SetDatabaseLogon("sa", "", "(local)", "ddl");
CrystalReportSource1.ReportDocument.SetParameterValue("fath", "2");
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();*/