2005水晶报表怎么绑定一个dataset,一个dataset里含有多个表,在线等

来源:百度知道 编辑:UC知道 时间:2024/05/09 19:42:44
2005水晶报表怎么绑定一个dataset,一个dataset里含有多个表,在线等,急急急!!!

ReportDocument doc = new ReportDocument();
doc.Load(Server.MapPath("CrystalReport1.rpt"));
TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();
tableLogOnInfo.ConnectionInfo.ServerName = "Computer";
tableLogOnInfo.ConnectionInfo.DatabaseName = "demo";
tableLogOnInfo.ConnectionInfo.UserID = "sa";
tableLogOnInfo.ConnectionInfo.Password = "sa";
doc.Database.Tables[0].ApplyLogOnInfo(tableLogOnInfo);

string strSql=select * from student ;
SqlDataAdapter sda = new SqlDataAdapter(strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds,"student");
doc.SetDataSource(ds);
//doc.Database.Tables[0].SetDataSource(ds.Tables["student"]);
doc.Database.Tables[0].SetDataSource(ds.Tables[0]);
crystalReportViewer.ReportSource = doc;