The Data Binding problem of the subreport in the crystal report is from the blog of haozidong.

Source: Internet
Author: User

Has it been plagued by data binding issues in subreports of Crystal Reports? This is also a question I mentioned in another article.

Http://www.cnblogs.com/haozidong/archive/2004/10/20/54489.html

You can bind a subreport with code to solve this problem.

String sconnectionstring = configurationsettings. receivettings ["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 has three word reports and dataset has three tables.
The preceding Code accesses each word report to bind data to subreports.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.