cancel
Showing results for 
Search instead for 
Did you mean: 

Changing DatabaseName and DatabaseServer on rpt file

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Moved to .NET SDK forum

Once you make the change then simply use the SaveAs option to save the updated info back to the hard drive. Make a back up of the reports first of course.

To flag if a report has been update you can use SummaryInfo to make a note, test if the note is there and if so ignore to set location and up, if not the set location and update the info and save.

You can either do it on the fly or create a simple one time update all reports app and be done with it.

Thank you

Don

Former Member
0 Kudos

Thank you Don. That was really helpful. One quick question..how do I know which type of ODBC(RDO) is used just by looking at the properties attributes in the datasource location of a report? What I mean is, is there a way to know whether it is a DSN or connection string or something else based on properties attributes on datasource location?

Thanks again very much for your reply!

0 Kudos

Lots of samples, try searching in the Knowledge base system.

Here is one example:

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_b...

Don

Answers (0)