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

change Database connection at runtime [DB2]

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on May 24, 2013 at 04:14 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 24, 2013 at 03:32 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2013 at 10:46 AM

    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 :-)

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

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.