Hi there,
Currently I have the necessity to change the database connection of my .RPT files using Java, but I have not found a way to do it. See my code below..
if(!CR_VIEWER_NAME.equals(request.getParameter(CR_VIEWER_EVENT_PARAM))) {
ReportClientDocument doc = new ReportClientDocument();
//doc.setReportAppServer(ReportClientDocument.inprocConnectionString); // Version 12+
doc.open(reportName, OpenReportOptions._openAsReadOnly);
reportSource= doc.getReportSource();
session.setAttribute("ReportSource", reportSource);
doc.close();
} else {
reportSource= session.getAttribute("ReportSource");
}
ConnectionInfos connInfos = new ConnectionInfos();
IConnectionInfo connInfo1 = new ConnectionInfo();
connInfo1.setUserName(DBUSERNAME);
connInfo1.setPassword(DBPASSWORD);
//To change the database connection of the current .RPT report, using PropertyBag
//connInfo1.setAttributes(propertyBag);
connInfos.add(connInfo1);
CrystalReportViewer viewer= new CrystalReportViewer();
viewer.refresh();
viewer.setHasExportButton(true);
viewer.setHasPrintButton(true);
viewer.setHasToggleGroupTreeButton(false);
viewer.setHasZoomFactorList(false);
viewer.setHasLogo(false);
viewer.setHasToggleParameterPanelButton(true);
viewer.setName(reportName.substring(1, reportName.indexOf(".")));
viewer.setReportSource(reportSource);
viewer.setEnableParameterPrompt(true);
viewer.setDatabaseLogonInfos(connInfos);
viewer.setEnableLogonPrompt(false);
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
Have you done this before? if so please give me the light!
Thank you so much in advanced. The lost.