是否被水晶报表中子报表的数据绑定问题折磨过?这也是我另一文章所说的问题
http://www.cnblogs.com/haozidong/archive/2004/10/20/54489.html
你可以通过单独用代码绑定子报表来解决这个问题。
string sConnectionString = ConfigurationSettings.AppSettings["dbCommISMS"];
SqlConnection sqlConn = new SqlConnection(sConnectionString);
SqlCommand sqlComm = new SqlCommand();
SqlDataAdapter dataAdapter = new SqlDataAdapter();
sqlConn.Open();
sqlComm.Connection = sqlConn;
sqlComm.CommandType = CommandType.Text;
dataAdapter.SelectCommand = sqlComm;
Dataset1 dataSet = new Dataset1();
string sSQL = "SELECT * FROM T_REQUEST WHERE APPLI_ID = '" + appli_id + "'";
sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_REQUEST");
sSQL = "SELECT * FROM T_REQUEST_INSPECTION WHERE APPLI_ID = '" + appli_id + "'";
sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_REQUEST_INSPECTION");
sSQL = "SELECT * FROM T_ACCEPT_INSPECTION WHERE APPLI_ID = '" + appli_id + "'";
sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_ACCEPT_INSPECTION");
SubreportObject oSubreport1 = oRpt.ReportFooterSection1.ReportObjects["Subreport1"] as SubreportObject;
ReportDocument oSub1 = oSubreport1.OpenSubreport("Inspection");
oSub1.SetDataSource(dataSet);
SubreportObject oSubreport2 = oRpt.ReportFooterSection2.ReportObjects["Subreport2"] as SubreportObject;
ReportDocument oSub2 = oSubreport1.OpenSubreport("Survey");
oSub2.SetDataSource(dataSet);
SubreportObject oSubreport3 = oRpt.ReportFooterSection2.ReportObjects["Subreport3"] as SubreportObject;
ReportDocument oSub3 = oSubreport1.OpenSubreport("Allonge");
oSub3.SetDataSource(dataSet);
oRpt.SetDataSource(dataSet);
oViewer.ReportSource = oRpt;
oRpt 有三个字报表,dataSet 有三个表。
上述代码通过访问每个字报表,来实现子报表数据绑定