Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Data Connectivity
Message Icon Topic: Data Source and Parameters inCRXI Post Reply Post New Topic
Author Message
grayside
Newbie
Newbie


Joined: 25 Sep 2009
Location: Philippines
Online Status: Offline
Posts: 1
Quote grayside Replybullet Topic: Data Source and Parameters inCRXI
    Posted: 25 Sep 2009 at 1:26am
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();
       
        //Set the datasource for all main report tables.
        for (int i = 0; i < tables.size(); i++) {
            ITable origTable = tables.getTable(i);
            ITable newTable =(ITable)((IClone) origTable).clone(true);
           
            //Keep existing name and alias.
            newTable.setName(DB_SCHEMA + newTable.getName());
            newTable.setAlias(newTable.getAlias());
           
            //Change properties that are different from the original datasource.
            origTable.setQualifiedName(newTable.getName());

            //Change connection information properties.
            IConnectionInfo connectionInfo = newTable.getConnectionInfo();
           
            //Set new table connection property attributes.
            PropertyBag propertyBag = new PropertyBag();
           
            //Overwrite any existing properties with updated values.
            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);
           
               
            rptClientDoc.getDataDefController().getDataDefinition().getParameterFields();
           
            connectionInfo.setUserName(USER_NAME);
            connectionInfo.setPassword(USER_PWD);
            connectionInfo.setKind(ConnectionInfoKind.SQL);
            newTable.setConnectionInfo(connectionInfo);
           
            //Update old table in the report with the new table.
            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...
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.014 seconds.