水晶报表 打印 主及子报表的数据源绑定

 //设置主报表数据源 

strSQL = "SELECT * FROM tbl_A where id = '" + ViewState["ID"].ToString() + "'";
                string strCon = ConfigurationManager.AppSettings["KSCCPLATConnectionString"];
                DataSet ds = SQLSrv.GeneralQuery(strSQL, strCon);
                ds.Tables[0].TableName = "tbl_A ";
                reportDocument = new ReportDocument();
                reportDocument.Load(Server.MapPath("../CR/JGRYDJ.rpt"));
                reportDocument.SetDataSource(ds);

                //设置子报表数据源
                DataSet dss = SQLSrv.GeneralQuery("SELECT * FROM tbl_Aa where jlid = '" + ds.Tables[0].Rows[0]["Id"].ToString() + "'", strCon);
                dss.Tables[0].TableName = "tbl_Aa";
                reportDocument.OpenSubreport("JGRYDJQTRY").SetDataSource(dss);

                CRV.ReportSource = reportDocument;

你可能感兴趣的:(水晶报表 打印 主及子报表的数据源绑定)