on 08-05-2011 10:11 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
Lots of samples, try searching in the Knowledge base system.
Here is one example:
Don
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.