我有一个带有2个数据表的数据集aand我需要使用2个sql请求来显示水晶报表中的数据。所以我在我的数据集中创建了2个数据表(DataTable1和dataTable2)我尝试了这个代码,但它总是执行第二个sql请求!!
con.ConnectionString = @"connection";
string sql = "MyRequest1";
string sql1 = "MyRequest2";
DataSet1 ds = new DataSet1();
SqlDataAdapter dad = new SqlDataAdapter(sql, con);
SqlDataAdapter dad1 = new SqlDataAdapter(sql1, con);
dad.Fill(ds.Tables["DataTable1"]);
dad1.Fill(ds.Tables["DataTable2"]);
CrystalReport1 report = new CrystalReport1();
report.SetDataSource(ds.Tables["DataTable2"]);
report.SetDataSource(ds.Tables["DataTable1"]);
crystalReportViewer1.ReportSource = report;
crystalReportViewer1.Refresh();