Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Change data provider in CR runtime code? Post Reply Post New Topic
Author Message
billux123
Newbie
Newbie


Joined: 03 Aug 2017
Online Status: Offline
Posts: 8
Quote billux123 Replybullet Topic: Change data provider in CR runtime code?
    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!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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
IP IP Logged
billux123
Newbie
Newbie


Joined: 03 Aug 2017
Online Status: Offline
Posts: 8
Quote billux123 Replybullet 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.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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/

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

-Dell

Edited by hilfy - 17 Aug 2017 at 5:13am
IP IP Logged
billux123
Newbie
Newbie


Joined: 03 Aug 2017
Online Status: Offline
Posts: 8
Quote billux123 Replybullet 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/

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?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 18 Aug 2017 at 5:40am
I'm not sure. You may have to.

-Dell
IP IP Logged
billux123
Newbie
Newbie


Joined: 03 Aug 2017
Online Status: Offline
Posts: 8
Quote billux123 Replybullet 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?
IP IP Logged
billux123
Newbie
Newbie


Joined: 03 Aug 2017
Online Status: Offline
Posts: 8
Quote billux123 Replybullet Posted: 22 Aug 2017 at 7:57am
I am almost a 100% sure this can't be done
IP IP Logged
billux123
Newbie
Newbie


Joined: 03 Aug 2017
Online Status: Offline
Posts: 8
Quote billux123 Replybullet 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/
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 25 Aug 2017 at 10:18am
Awesome!

-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.027 seconds.