Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Passing Values to Crystal Reports Enterprise at runtime.

$
0
0

Hi,

 

   I have several reports that I am migrating from 2011 to CR Enterprise. Here is the code that I am using to view the report using Crystal Report Viewer contraol in my web application.

 

sessionMgr = newSessionMgr();

enterpriseSession = sessionMgr.Logon("user", "psswd", "server", "Enterprise");

EnterpriseService enterpriseService = enterpriseSession.GetService("InfoStore");

InfoStore infoStore = newInfoStore(enterpriseService);

String infoQuery = String.Format("SELECT TOP 1 * FROM CI_INFOOBJECTS WHERE SI_PROGID='CrystalEnterprise.Report' AND " +

                                                  " SI_NAME LIKE '%{0}%' ORDER BY SI_Creation_Time desc", "TestProduct");

InfoObjects infoObjects = infoStore.Query(infoQuery);

InfoObject infoObject = infoObjects[1];

PSReportFactory factory = (PSReportFactory)enterpriseSession.GetService("PSReportFactory").Interface;

ISCRReportSource reportSource = factory.OpenReportSource(infoObject.ID);

this.CrystalReportViewer1.ReportSource = reportSource;

 

However when I try to set the parameters to the Crystal Report Viewer using the CrystalReportViewer1.ParameterFieldInfo, the code

does not seem to recognize the value I am setting programatically and the Crystal Native Parameter prompt keeps appearing.Here is the code that I am using to set the value.

 

ParameterFields pFields = new ParameterFields();

ParameterField pField = new ParameterField();

ParameterDiscreteValue disValue = new ParameterDiscreteValue();

disValue.Value = "TEST";

pField.CurrentValues.Add(disValue);

pFields.Add(pField);

this.CrystalReportViewer1.ParameterFieldInfo = pFields;

 

What am I doing wrong? where I can find some samples.


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>