Print Page | Close Window

Change data provider in CR runtime code?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22410
Printed Date: 23 Apr 2024 at 3:28am


Topic: Change data provider in CR runtime code?
Posted By: billux123
Subject: Change data provider in CR runtime code?
Date Posted: 10 Aug 2017 at 9:28am
Is there any way to change the data provider in the crystal runtime code to a different provider than what was set in the IDE while building the report? I have a situation where I have over 600 rpt files that were created with "Microsoft OLE DB Provider for SQL Server" and I need to now run these reports with the "SQL Server Native Client 11.0" provider on our servers with the crystal runtime. We really don't want to have to go back and manually switch the provider in all of our report files!

Thanks!



Replies:
Posted By: hilfy
Date Posted: 11 Aug 2017 at 5:01am
If you're using the "runtime", that means that you're running the reports through an application. Is this an application that you or your employer have written or is it a third-party application.

If you or your employer have written the application, then yes, you can change the provider at run time. You can find an example for how to do this here: https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports+for+.NET+SDK+Samples#CrystalReportsfor.NETSDKSamples-Database.

If you're running a third-party application, then there's probably no way of doing this at runtime. However, it wouldn't be difficult to write an application that will open each report, change the data provider, then save the report so that it has the correct provider when it runs.

-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: billux123
Date Posted: 17 Aug 2017 at 4:27am
Originally posted by hilfy

If you're using the "runtime", that means that you're running the reports through an application. Is this an application that you or your employer have written or is it a third-party application.

If you or your employer have written the application, then yes, you can change the provider at run time. You can find an example for how to do this here: https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports+for+.NET+SDK+Samples#CrystalReportsfor.NETSDKSamples-Database.

If you're running a third-party application, then there's probably no way of doing this at runtime. However, it wouldn't be difficult to write an application that will open each report, change the data provider, then save the report so that it has the correct provider when it runs.

-Dell


Yes I am trying to run reports from with in my own custom built application. Do you know what property I can use to change the provider? I looked threw the examples you provided and could not find an example of when the provider was being changed.


Posted By: hilfy
Date Posted: 17 Aug 2017 at 5:12am
Although this talks about parameters, it also contains info about how to change the database driver.

https://blogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-for-visual-studio-net/ - https://blogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-for-visual-studio-net/

It has a link to an SAP Note where you can download the code for the application.

-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: billux123
Date Posted: 18 Aug 2017 at 4:52am
Originally posted by hilfy

Although this talks about parameters, it also contains info about how to change the database driver.

https://blogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-for-visual-studio-net/ - https://blogs.sap.com/2016/02/17/how-to-parameters-in-crystal-reports-for-visual-studio-net/

It has a link to an SAP Note where you can download the code for the application.

-Dell


I have written code that changes the provider info in the logon properties before the runtime exports the file. But I still get a logon failed exception. Do I have to change the provider with code then save it back to the rpt file before I try to run the file with the runtime?


Posted By: hilfy
Date Posted: 18 Aug 2017 at 5:40am
I'm not sure. You may have to.

-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: billux123
Date Posted: 18 Aug 2017 at 7:41am
Originally posted by hilfy

I'm not sure. You may have to.

-Dell


So after I changed all the properties I added code to write the rpt file to disk. I opened the rpt file with the Crystal IDE and all the database connection settings were blown away. Why would this happen?


Posted By: billux123
Date Posted: 22 Aug 2017 at 7:57am
I am almost a 100% sure this can't be done


Posted By: billux123
Date Posted: 25 Aug 2017 at 9:33am
I solved it! I followed the info from this post.

https://blogs.sap.com/2011/09/02/when-to-use-the-replace-connection-method-using-the-crystal-reports-or-inproc-ras-sdk-for-net/


Posted By: hilfy
Date Posted: 25 Aug 2017 at 10:18am
Awesome!

-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window