Passing a SQL Input Parameter to a Crystal Report Subreport

G

Guest

I'm successfully passing a SQL Input Parameter when calling a Crystal Report,
so that the user doesn't get prompted. But I can't seem to find a way to pass
it the subreport.

Code for main report:
Dim ParameterFields As New ParameterFields
Dim ParameterField As New ParameterField
Dim spValue As New ParameterDiscreteValue

ParameterField.ParameterFieldName = "@ReportGUIDString"
spValue.Value = mSearchID
ParameterField.CurrentValues.Add(spValue)
ParameterFields.Add(ParameterField)

'Pass Input Param
Me.CrystalReportViewer1.ParameterFieldInfo = ParameterFields

'Link Report Instance with Viewer
Me.CrystalReportViewer1.ReportSource = ClientReportV1

The problem appears that you link the Parameter to the Viewer, opposed to
the report. How do I pass the parameter to the subreport?

I tried the following code but it didn't work:
Dim SummarySubReport As New ReportDocument
SummarySubReport = ClientReportV1.OpenSubreport("Summary Totals")
SummarySubReport.SetParameterValue("@ReportGUIDString", mSearchID)

Thanks.
 
W

Wei-Dong XU [MSFT]

Hi,

Currently I am finding one support professional for you on this issue. When
any update, we will reply here at the first time.

Best Regards,
Wei-Dong XU
Microsoft Product Support Services
This posting is provided "AS IS" with no warranties, and confers no rights.
It is my pleasure to be of assistance.
 
A

Ayaz Ahmed

Hello,

This is my C# Code.Please convert this code into vb.net


protected CrystalDecisions.Web.CrystalReportViewer CRViewer;
private Tables crTables;
private CrystalDecisions.CrystalReports.Engine.Table crTable;
private TableLogOnInfo crTableLogOnInfo;
TestReport crReportDocument=new TestReport();
private ConnectionInfo crConnectionInfo = new ConnectionInfo();
string databaseServer, databaseName, databaseUser, UserPassword;



ReportDocument crSubreportDocument;
Sections crSections;
SubreportObject crSubreportObject;
ReportObjects crReportObjects;
Database crDatabase;
Tables crTables;

crConnectionInfo.ServerName = databaseServer;//"AYAZ";
crConnectionInfo.DatabaseName = databaseName;//"DB";
crConnectionInfo.UserID = databaseUser;//"sa";
crConnectionInfo.Password = UserPassword;//"sa";

crTables = crReportDocument.Database.Tables;
for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables ;
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
crTable.Location =
crTable.Location.Substring(crTable.Location.LastIndexOf (".") + 1) ;
}

crSections = crReportDocument.ReportDefinition.Sections;
foreach (Section crSection in crSections)
{
crReportObjects = crSection.ReportObjects;
foreach (ReportObject crReportObject in crReportObjects)
{
if (crReportObject.Kind == ReportObjectKind.SubreportObject)
{
crSubreportObject = (SubreportObject) crReportObject;
crSubreportDocument =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
crDatabase = crSubreportDocument.Database;
crTables = crDatabase.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in
crTables)
{
crTableLogOnInfo = aTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
aTable.ApplyLogOnInfo(crTableLogOnInfo);
}
}
}
}

crReportDocument.SetParameterValue(@ToYear,YearVariable,crSubreportDocum
ent)
CRViewer.ReportSource = crReportDocument;


Regards,

Ayaz Ahmed
Project Manager
Creative Chaos (Pvt.) Ltd.
"Managing Your Digital Risk"
http://www.csquareonline.com
Mobile +92 300 2280950
Office +92 21 455 2414
Email: (e-mail address removed)
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top