DataTable dt = new DataTable();
string conn = "server=(local);integrated security=sspi;database=northwind";
SqlConnection SqlConn = new SqlConnection(conn);
SqlConn.Open();
SqlCommand cmd = new SqlCommand("select * from products", SqlConn);
SqlDataAdapter SDA = new SqlDataAdapter(cmd);
SDA.Fill(dt);
CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(dt);
CrystalReportViewer1.ReportSource=CrystalReportSource1.ReportDocument;
CrystalReportSource1.DataBind();
//动态改变标题
TextObject to = (TextObject)CrystalReportSource1.ReportDocument.ReportDefinition.ReportObjects["title1"];
to.Text = "hahhahah";