on 09-26-2009 12:07 PM
Good day Sirs:
this is my first post here, should i violate any rules, please accept my humblest apologies.
I would like to ask your help regarding my problem. Im using Eclipse Europa and Crystal Reports XI. What I would like to do is to dynamically change the DataSource of my Crystal Report. I believe I have done that with the following codes:
Tables tables = rptClientDoc.getDatabaseController().getDatabase().getTables();
for (int i = 0; i < tables.size(); i) {
ITable origTable = tables.getTable(i);
ITable newTable =(ITable)((IClone) origTable).clone(true);
+newTable.setName(DB_SCHEMA + newTable.getName());+
newTable.setAlias(newTable.getAlias());
origTable.setQualifiedName(newTable.getName());
IConnectionInfo connectionInfo = newTable.getConnectionInfo();
PropertyBag propertyBag = new PropertyBag();
propertyBag.put("Trusted_Connection", "false");
propertyBag.put("Server Name", SERVER_NAME);
propertyBag.put("Connection String", CONNECTION_STRING);
propertyBag.put("Database Name", DB_NAME);
propertyBag.put("Server Type", "JDBC (JNDI)");
propertyBag.put("URI", URI);
propertyBag.put("Use JDBC", "true");
propertyBag.put("Database DLL", DB_DLL);
connectionInfo.setAttributes(propertyBag);
rptClientDoc.getDataDefController().getDataDefinition().getParameterFields();
connectionInfo.setUserName(USER_NAME);
connectionInfo.setPassword(USER_PWD);
connectionInfo.setKind(ConnectionInfoKind.SQL);
newTable.setConnectionInfo(connectionInfo);
rptClientDoc.getDatabaseController().setTableLocation(origTable,newTable);
}
But I recieve this Error Message: JRCAgent1 detected an exception: No results were returned by the query.
It seems that my Parameters are not seen by the query, having this code:
ParameterFieldController paramFieldController = rptClientDoc.getDataDefController().getParameterFieldController();
Fields params = rptClientDoc.getDataDefController().getDataDefinition().getParameterFields();
for (int j = 0; j < params.size(); j++) {
IParameterField parameterField = (IParameterField) params.getField(j);
}
Your help will be a great lift to my dipping morale...
Thank you very much and I hope to hear from anybody soon...
Edited by: grayscale on Sep 28, 2009 8:34 AM
Please download the following sample and modify the code according to your requirement:
[http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/f0ad3d3d-be66-2b10-2181-f46c6e05a420]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sir, thank you very much for your reply. The sample codes were very much helpful. I could now successfully change data source dynamically.
But still, I encounter error messages: JRCAgent1 detected an exception: No results were returned by the query.
which leads me to conclusion that, the parameters are "left out"
Sir, thanks for your reply again. But Im encountering an error im not familiar with:
Failed to load the resource 'ProgrammingError' from the bundle java.util.PropertyResourceBundle@17b1c02.
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key ProgrammingError
This occurs in .setTableLocation() line.
Please excuse my ignorance. Thank you very much again
Found out what causing the error. Its from a wrong Stored Procedure Name I passes (Forgive me for that).
What I did next was to set the parameters for the Stored Procedure via the ff codes:
for (int i = 0; i < tables.size(); i++) {
IProcedure table = (IProcedure)tables.getTable(i);
table.setName(spName);
table.setAlias(spName);
table.setParameters(params);
...
}
Im now having this error: JRCAgent1 detected an exception: Unknown EROM field value type
Good day Sirs:
this is my first post here, should i violate any rules, please accept my humblest apologies.
I would like to ask your help regarding my problem. Im using Eclipse Europa and Crystal Reports XI. What I would like to do is to dynamically change the DataSource of my Crystal Report. I believe I have done that with the following codes:
Tables tables = rptClientDoc.getDatabaseController().getDatabase().getTables();
for (int i = 0; i < tables.size(); i++) {
ITable origTable = tables.getTable(i);
ITable newTable =(ITable)((IClone) origTable).clone(true);
newTable.setName(DB_SCHEMA + newTable.getName());
newTable.setAlias(newTable.getAlias());
origTable.setQualifiedName(newTable.getName());
IConnectionInfo connectionInfo = newTable.getConnectionInfo();
PropertyBag propertyBag = new PropertyBag();
propertyBag.put("Trusted_Connection", "false");
propertyBag.put("Server Name", SERVER_NAME); //Optional property.
propertyBag.put("Connection String", CONNECTION_STRING);
propertyBag.put("Database Name", DB_NAME);
propertyBag.put("Server Type", "JDBC (JNDI)");
propertyBag.put("URI", URI);
propertyBag.put("Use JDBC", "true");
propertyBag.put("Database DLL", DB_DLL);
connectionInfo.setAttributes(propertyBag);
connectionInfo.setUserName(USER_NAME);
connectionInfo.setPassword(USER_PWD);
connectionInfo.setKind(ConnectionInfoKind.SQL);
newTable.setConnectionInfo(connectionInfo);
rptClientDoc.getDatabaseController().setTableLocation(origTable,newTable);
}
But still recieve messages and I think I am missing the Parameters though I have set it via this code:
ParameterFieldController paramFieldController = rptClientDoc.getDataDefController().getParameterFieldController();
Fields params = rptClientDoc.getDataDefController().getDataDefinition().getParameterFields();
for (int j = 0; j < params.size(); j++) {
IParameterField parameterField = (IParameterField) params.getField(j);
}
Your help will be a great lift to my dipping morale...
Thank you very much and I hope to hear from anybody soon...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please download the following sample and modify the code according to your requirement:
[http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/f0ad3d3d-be66-2b10-2181-f46c6e05a420]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.