cancel
Showing results for 
Search instead for 
Did you mean: 

Problem setting table location on Oracle report in C#

Former Member
0 Kudos

Crystal 2008 (Full Version).

C#

.NET 3.5

I have a simple report that has one database table (operator). When I run the report in C#, I am attempting to redirect to another table (operator123) in the same database. When I connect to a SQL Sever 2005 database, this works fine. But when connected to an Oracle 10g database the table does not redirect correctly. I am connecting via an ODBC DSN.

Here is the code that Iu2019m using:

ReportDocument rpt = new ReportDocument();
rpt.Load("C:\\OperatorList.rpt");
rpt.DataSourceConnections[0].SetConnection("mydsn", null, "myid", "mypw");
foreach (CrystalDecisions.CrystalReports.Engine.Table eachTable in rpt.Database.Tables)
{
    if (eachTable.Name.ToLower() == "operator")
    {
        eachTable.Location = "operator123";
    }
}

When I run this, the report still uses data from the u201Coperatoru201D table. I can put in a table name that does not exist, and the report still uses the u201Coperatoru201D table. Iu2019ve tried doing a rpt.VerifyDatabase() with the bad table name, but this does not return an exception.

If I add a qualifier to the table name, I get an exception:

eachTable.Location = "myid.operator123";

System.Runtime.InteropServices.COMException occurred. The table 'OPERATOR' could not be found.

I get this exception anytime my new table location contains a period, regardless if it is valid or not.

Any suggestions?

Thanks,

Skip

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello, Skip;

Do you have any updates installed for Crystal Reports 2008?

Can you connect to the same Oracle database outside of Crystal Reports from that system?

What version of the Oracle client is installed?

What are the database properties for Oracle in your report? Open the report in the designer and go to Database|Set datasource location.

Is the report created with ODBC? Has the DSN changed?

If you expand the Table properties, has the Owner changed? Table.Location is only needed if the Owner or tablename has changed.

Table.Location = "OWNER.TableName"

Note that Oracle is case sensitive. It should be as you see in the report.

What driver did you use to create the ODBC DSN - an Oracle client driver or a Crystal Reports Oracle driver?

ConnectionInfo for the Oracle Native driver is:

ConnectionInfo.DatabaseName = "" 'empty string for Oracle

ConnectionInfo.UserID = "uid"

ConnectionInfo.Password = "pwd"

'Pass the Server name for Native and OLEDB. The DSN name for ODBC.

ConnectionInfo.ServerName = "serverName"

Let me know what you find.

Elaine

Former Member
0 Kudos

Elaine,

My problem was case sensitivity. When I changed my code to use all uppercase for the table name it started working! Thanks for your help!

Skip

Answers (0)