5

We have hundreds of Reports created in 8.0.1.0 (I know they are old).

We created a Visual Studio 2010 C# application to run these reports. It's a Windows App. Had some trouble with the Web App.

The reports are all saved under the PROD environment.

We are working in a TEST environment.

We are using an Oracle environment and all the reports use the Oracle Server connection.

When we run the reports through C# we go ahead and change all the database locations to our TEST environment. When this happens the "Owner" (schema) information is dropped. The report fails with a 942 error.

Now if we don't change the database, keep it as PROD, everything works perfectly. It seems that by changing the database the schema information is dropped.

Any ideas. I've been searching around and can't find a solution.

Snippet of code:

connectionInfo.DatabaseName = "";
connectionInfo.ServerName = <SERVER>;
connectionInfo.UserID = <USER>;
connectionInfo.Password =  <PWORD>;

foreach (Table crTable in crTables)
        {
            crTableLogOnInfo = crTable.LogOnInfo;
            crTableLogOnInfo.ConnectionInfo = connectionInfo;
            crTable.ApplyLogOnInfo(crTableLogOnInfo);

            // if you wish to change the schema name as well, you will need to set Location property as follows:
             //crTable.Location = "<SCHEMA>." + crTable.Name;

        }

I've tried to set the crTable.Location but the program locks up. So not sure what to do.

4

2 回答 2

1

过去我们通过这样做成功地更改了连接参数:

CrystalDecisions.Shared.TableLogOnInfo info = document.Database.Tables[iTable].LogOnInfo.Clone() as CrystalDecisions.Shared.TableLogOnInfo;

info.ConnectionInfo.ServerName = <SERVER>;
info.ConnectionInfo.DatabaseName = "";
info.ConnectionInfo.UserID = <USER>;
info.ConnectionInfo.Password = <PASSWORD>;

document.Database.Tables[iTable].ApplyLogOnInfo(info);

document在哪里CrystalDecisions.CrystalReports.Engine.ReportDocument

于 2012-11-28T22:20:16.483 回答
1

通过这样做修复它:

connectionInfo.DatabaseName = "";
connectionInfo.ServerName = <SERVER>;
connectionInfo.UserID = <USER>;
connectionInfo.Password =  <PWORD>;

foreach (Table crTable in crTables)
    {
        crTableLogOnInfo = crTable.LogOnInfo;
        crTableLogOnInfo.ConnectionInfo = connectionInfo;
        crTable.ApplyLogOnInfo(crTableLogOnInfo);

        // if you wish to change the schema name as well, you will need to set   Location property as follows:
         //crTable.Location = "<SCHEMA>." + crTable.Name;
         crTable.Location = "<SCHEMA>." + crTable.LogOnInfo.TableName;

    }

我错误地设置了位置。谢谢你的帮助!

于 2012-11-29T19:54:10.790 回答