Skip to Content
0
Former Member
Aug 05, 2011 at 09:11 PM

Changing DatabaseName and DatabaseServer on rpt file

94 Views

Hello,

I have inherited around 500 crystal reports where the datasource location is a ODBC(RDO) but pointing to actual databaseserver and databasename. Properties on the datasource look as follows:

Database Tyoe: ODBC(RDO)

Server Name: XYZ

User ID : User

DataBase: XYZ

User DSN Default Properies: True

We changed to a new database server and database name is also changed so we would like it be like this:

Database Tyoe: ODBC(RDO)

Server Name: ABC

User ID : User

DataBase: NewDB

User DSN Default Properies: True

I used the code following code on all the rpt files to change the information. But when I open the report after running the script it is still showing the old database information.

report.Load(@"C:\Development\Crystal Test\report1.rpt");

// Change the server name and database in main reports

foreach (CrystalDecisions.Shared.IConnectionInfo connection in report.DataSourceConnections)

{

if ((String.Compare(connection.ServerName, "XYZ", true) == 0) &&

(String.Compare(connection.DatabaseName, "XYZ", true) == 0))

{

report.DataSourceConnections[" "XYZ", "XYZ"].SetConnection(

"ABC", "NewDB", "User", "");

}

}

On further research I found that this will change on the temporary copy of the report but not on actual. Is there anyway to change the database information on all the of the 500 reports without doing manually? I really appreciate your help.

Thanks in advance