Skip to Content
author's profile photo Former Member
Former Member

How can I use C# to run same report on multiple MS SQL DBs?

up vote0down votefavorite

Hello SAP Community! I am a Systems Engineer for a software company and we are evaluating SAP Crystal Reports to see if it will suit our needs. I've downloaded a trial and am trying to create a test application to see if this will work but I'm a little stumped.

I'm using SAP Crystal Reports 2016 with the Visual Studio plugin, along with Visual Studio 2015.

What I've done is created a simple MDI application using C# in Visual Studio which contains multiple Crystal Reports Viewer forms which open an embedded report in a child window when the menu item is clicked. This application will sit on our development server and be used to run reports against client databases that get sent to us with problems.

Here's the issue: We've got multiple instances (and versions) of SQL Server running and we are getting multiple test databases daily which of course will be named differently. The reports are looking for one specific database only, because the report was created in CR looking for a specific ODBC connection via the Database Expert.

What I would like to do, is either on form load or via a button click, be able to have a box prompt the user for server and database name. For example:

SQLServer\SuperCoolInstance 
My_Cool_Database

The report would then connect to that database and display relevant information. I thought I should point out that all the SQL Server databases that this would run on would have identical schema but of course different data.

I want to be able to pass connection info from the application to the report instead of using the embedded datasource in the report.

Any idea on how I could accomplish this? Second best scenario would be to have something like an XML file that contains the server and database and the program looks at that when launching. Even though we'd have to edit the XML whenever we wanted to change datasources it would be something! I wouldn't know how to pursue that avenue either though.

Thanks very much in advance for any ideas or guidance.

Cheers.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Aug 22, 2016 at 01:46 PM

    Hi Ethan,

    You can get the data source info from the report, then using Windows API's create the DSN based on the info from the report and now the report should simply work, you will need to set the password.

    Search for KBA 2281780 which points to a DOC file with a test app attached, it's for parameters but has code to set log on info. See if that helps you, it has code on getting the connection info from the report and subreports.

    Don

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.