Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the database location drops owner schema

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.

like image 986
madkow Avatar asked Nov 04 '22 10:11

madkow


2 Answers

In the past we successfully changed connection parameters by doing this:

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);

where document is CrystalDecisions.CrystalReports.Engine.ReportDocument.

like image 195
Igor Avatar answered Nov 09 '22 21:11

Igor


Fixed it by doing this:

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;

    }

I was setting the Location incorrectly. Thanks for your help!

like image 44
madkow Avatar answered Nov 09 '22 22:11

madkow