Skip to Content
0
Former Member
Dec 01, 2006 at 08:14 AM

JRC Changing Database with reports with Command Tables

54 Views

<p>I&#39;m somewhat new to Crystal Reports, so may have missed something, below is the code im using (The variables that you cant see defined are somewhat self explanatory)<br /></p><p>&nbsp;</p><p>String dbURL = "jdbc:microsoft:sqlserver://";<br />dbURL += dbServer;<br />dbURL += ":";<br />dbURL += dbPort;<br /><br />String dbURI = "!";<br />dbURI += dbJDBCDriver;<br />dbURI += "!";<br />dbURI += dbURL;<br />dbURI = ";DatabaseName=;user=;password=!ServerType=1!QuoteChar=\"";<br /><br />String dbConnStr = "Use JDBC=b(true);Connection URL=s("dbURL");" <br /> + "Database Class Name=s("dbJDBCDriver");Server=s("dbServer");" <br /> + "User ID=s("dbUser");Password=s("dbPwd");Database=s("dbName");Trusted_Connection=b(false);" <br /> + "JDBC Connection String=s(!"dbJDBCDriver"!"dbURL";" + "DatabaseName=;user=;password=!)";<br /><br />try {<br /><br /> ReportClientDocument reportClientDoc = new ReportClientDocument();<br /> reportClientDoc.open(REPORT_NAME, 0);<br /> <br /> {<br /> Tables tables = reportClientDoc.getDatabaseController().getDatabase().getTables();<br /><br /><br /> for (int i = 0; i < tables.size(); i+)
{

ITable table = tables.getTable(i);

table.setName(table.getName());
table.setAlias(table.getAlias());

table.setQualifiedName(dbName + ".dbo." + table.getName());

IConnectionInfo connectionInfo = table.getConnectionInfo();
PropertyBag propertyBag = new PropertyBag();
propertyBag.put("Trusted_Connection", "false");
propertyBag.put("Server Name", dbServer); //Optional property.
propertyBag.put("Connection String", dbConnStr);
propertyBag.put("Database Name", dbName);
propertyBag.put("Server Type", "JDBC");
propertyBag.put("URI", dbURI);
propertyBag.put("Use JDBC", "true");
propertyBag.put("Database DLL", "crdb_jdbc.dll");

connectionInfo.setAttributes(propertyBag);

connectionInfo.setUserName(dbUser);
connectionInfo.setPassword(dbPwd);
connectionInfo.setKind(ConnectionInfoKind.SQL);

table.setConnectionInfo(connectionInfo);

reportClientDoc.getDatabaseController().setTableLocation(table, tables.getTable(i));

}
}

// << SUB REPORT CODE >>

session.setAttribute("reportSource", reportClientDoc.getReportSource());

response.sendRedirect("CrystalReportViewer.jsp");

}

 

Now this code seems to work fine, until you try and use a report, where the table is defined with a command, instead of just the normal database table.

when you use a command it throws the following exception

 

com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Invalid alias name.---- Error code:-2147467259 Error code name:failed at com.crystaldecisions.sdk.occa.report.lib.ReportSDKException.throwReportSDKException(Unknown Source) at com.businessobjects.reports.sdk.b.e.a(Unknown Source) at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source) at com.crystaldecisions.proxy.remoteagent.y.a(Unknown Source) at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.cf.a(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.z.a(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.ak.if(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.ad.int(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.bk.for(Unknown Source) at com.crystaldecisions.proxy.remoteagent.v.a(Unknown Source) at com.crystaldecisions.proxy.remoteagent.v.if(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(Unknown Source) at com.crystaldecisions.sdk.occa.report.application.DatabaseController.setTableLocation(Unknown Source) at com.crystaldecisions.reports.sdk.DatabaseController.setTableLocation(Unknown Source) at org.apache.jsp.reporting.view_005freport_jsp._jspService(org.apache.jsp.reporting.view_005freport_jsp:150) (... etc)

Running on Windows XP with Tomcat 5, any assistance would be great :D

 

- Matt