首页 > 开发 > 综合 > 正文

水晶报表中子报表的数据绑定问题

2024-07-21 02:25:05
字体:
来源:转载
供稿:网友

是否被水晶报表中子报表的数据绑定问题折磨过?这也是我另一文章所说的问题

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 有三个表。
上述代码通过访问每个字报表,来实现子报表数据绑定


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表