cancel
Showing results for 
Search instead for 
Did you mean: 

Issue changing table location within C# using Oracle in Crystal Reports

Former Member
0 Kudos

Post Author: kbj

CA Forum: .NET

We have prepared parameter-based reports that are given to multiple customers. After upgrading to Crystal Reports 11.5 (R2) in order support our overall upgrade to .Net 2.0, we are unable to get these reports working with parameters on multiple database. Since all of our customers have unique installations of an Oracle database (some with unique tablespace names), we need to be able to change the database logon information and table location at runtime. This is necessary so that we can design a single report for all our customers, or share reports between customers that they have made. This was working with previous versions of Crystal Reports (v11). The following is the code that we have employed to update the logon and table location information:

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)

{

// update the logon information for the database connection

reportDocument.SetDatabaseLogon(connectionInfo.UserID, connectionInfo.Password, connectionInfo.ServerName, "", false);

// update each individual datasource

for (int index = 0; index < reportDocument.DataSourceConnections.Count; index++)

{

reportDocument.DataSourceConnections&#91;index&#93;.SetConnection(connectionInfo.ServerName, "", connectionInfo.UserID, connectionInfo.Password);

reportDocument.DataSourceConnections&#91;index&#93;.SetLogon(connectionInfo.UserID, connectionInfo.Password);

}

// update the table connections

Tables tables = reportDocument.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

{

// except for updating the table location, this appears to be redundant

// logon modification with updating the datasource above

TableLogOnInfo tableLogonInfo = table.LogOnInfo;

tableLogonInfo.ConnectionInfo = connectionInfo;

table.ApplyLogOnInfo(tableLogonInfo);

// the User ID and Tablespace names agree in our setup (eg MYTABLESPACE.EXPERIMENT_SUMMARY)

// this update is needed to modify the Table's "Owner" Property. However,

// it appears to remove the parameter field's datasource;

table.Location = connectionInfo.UserID + "." + table.Name;

table.TestConnectivity();

}

// .Net 2005 Release notes for Crystal Reports indicates that this is necessary

reportDocument.VerifyDatabase();

}

Everything seems to work correctly until we update the table.location value. Since tables exist within tablespaces inside the Oracle database, we need to update the location with a "tablespace dot table" forrmat (TABLESPACE.TABLENAME). This does seem to update the corresponding "Owner" property of the table within the report. However, subsequent execution of the report after gives an error "The parameter is incorrect". After inspecting the modified report, it appears that the Data Source definition on each Parameter Field of the report has been deleted after changing the table location at runtime. Is this a bug in the runtime? Is there a work around or should we be changing the "Owner" property of the Table via some other method?

Any quick help or advice would be greatly appreciated!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

kbj, did you make any progress on this issue?

I'm having a similar problem pointing to tables in an Oracle database. See this [thread|;.

--

Tim

Answers (0)