Skip to Content
0
Former Member
Aug 06, 2011 at 12:56 AM

Modify datasource on reports

24 Views

I am pretty new to crystal reports. 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 recently moved to a new database server and the database name is also changed so we would like the datasource on the report to 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.

Also I am not sure if the original developer has used a DSN or the connection string in the datasource. Is there a way to know it or differentiate between various odbc(rdo) database types?

Thanks in advance