Skip to Content
0
Former Member
Jul 27, 2016 at 09:22 AM

VS2010 open report (with subreport) issue

75 Views

Hi All :

If the main report have one sub report, and I have define the field link between main report and subreport.

When the vs2010, I have write the code as below

_Cnn.Open();

SqlCommand _cmd = new SqlCommand("SELECT ID, STUDENTNAME, CLASSNUM'", _Cnn);

SqlDataReader _reader = _cmd.ExecuteReader();

DataTable _dt1 = new DataTable();

_dt1.Load(_reader);

_cmd = null;

_reader = null;

_cmd = new SqlCommand("SELECT STUDENTID , CLASSBOOK FROM LIBARYN", _Cnn);

_reader = _cmd.ExecuteReader();

DataTable _dt2 = new DataTable();

_dt2.Load(_reader);

ReportDocument _Report = new ReportDocument();

string _report = @"reportstgetReport.rpt";

_Report.Load(_report);

_Report.SetDataSource(_dt1);

_Report.OpenSubreport("subreport").SetDataSource(_dt2);

crv.ReportSource = _Report;

The reportviewer will prompt to input value of parameter field (but this parameter field is link field between main report and sub report).

How to handle it ?

Michael