cancel
Showing results for 
Search instead for 
Did you mean: 

change Database connection at runtime [DB2]

Former Member
0 Kudos

Hello folks,

I'm software developer in C#.Net and DB2 Database enviromnent. For a future release we are evalulating crystal reports at the moment. We playing with "integrated reports from dataset" (dataset is already present in our application) and "custom reports from SQL Command" (customer design its own Report with crystal report Developer or what ever and uses a (SQL-)Command).

The case "integrated reports from dataset" is very easy for us and we think it is very usefull.

But the case "custom reports from SQL Command" is totaly hell! The Report stores all connection data and wants allways to connect to the "designer database". We want to change the connection data of the report at runtime, but the customer SQL Command should not touched. We just want to fire these command against another database.

I googled a lot, tryed out some examples for this forum here but I dont found a working solution for our use case. I also tryed out the CodeBuilder-RasConnectionInfo, that should build me a working new database connection, but it doesnt.

So my question:

How can I change the database connection of a given crytal report at runtime with C#.Net? We need to pass the report all TCP/IP connection information about our DB2 database server: IP-adress/hostname, Port, Username, Passwort, maybe Schemaname.

Note: i have a second problem, the c# Reportviewer asked me once connection data for a report. Badly i checked something like "use integrated authentication" or "use OS authentication" or "save Logon data". Badly the connection information i provided was invalid and the report viewer ask me never again to enter an authentication. So every test with a working, unmodified report fails to. How can I reset the "memory" of the report viewer? Uninstallation of crytal report doesnt work.

Thank you very much!

Marcus

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Markus,

First I moved your post to the SDK forum.

To undo the Trusted Authentication option use the Set Location option in the Database menu drop down.

The problem is you can't set a report based on a Command object to a DB connection. You can from a DB connection against Tables to a Command, up to 2 tables only.

Only option is to continue using the Command Object.

Also, there are limitation to using DataSets and limited to memory space so I suggest if you go that route use XML as a datasource and not a Dataset.

Don

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Don,

thanks for your replay. Currently your answer is the most useful statement that I have found in the web since one week Im googling for help! 🙂

If I understand you right, its imposible to switch a TCP/IP db connection at runtime? I only have the option to set another table at runtime if I want to use another db as data source?

"Only option is to continue using the Command Object."

Is it possible to "clone" the existing Command Object at runtime but with another db connection? E.g. in the manner of the

NET-CS2003 RAS-Unmanaged CR115 Modify Command-Table-SQL

Example Application?

Is there somewhere a complete API reference where I can figure out some possiblities by myself?

To the Datasets: I think these limitations are fine for our project. We dont want to fill millions of datarows into a report. Maybe 200k rows as peak value, also only for longtime chart applications.

Thank you very much

Marcus 🙂

0 Kudos

Hi Marcus,

Go to help.sap.com, you'll find all of the updated and latest SDK help files there.

CR doesn't care how the Client connects to the Server, TCP/IP or DNS names, that's all handled by the DB Client. What Cr cares about is how you connect and which driver used.

Usually using the .SetLocation API' methods should work when a report is based on Tables and setting to a DataSet. Only thing that is a must is the field Types MUST match, if they don't you will get log on errors or the field is removed from the report.

Don

former_member183750
Active Contributor
0 Kudos

Hello Marcus

See the sample app NET-CS2003_RAS-Unmanaged_CR115_Modify_Command-Table-SQL

This sample application shows how to retrieve and change the text of a SQL command table from a Crystal Report using the CR .NET SDK and in-process Report Application Server (RAS) Report Creation API (RCAPI).

You don't mention what version of CR you are working with or version of VS, so I can only assume that you have the InProc RAS SDK available.

Re. your second query, please create a new thread. This is part of the Rules of Engagementand for the most part this rule is only there so that searching SCN is easier for those following in your footsteps .

If you let me know your version of CR and VS, I should be able to provide more resources.

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Hello Ludek,

thanks for your responce. I already know that example (like many others 😉 ) but it dont match our purpose.

Thanks anyway 🙂

Take care

Marcus