Print Page | Close Window

Crystal Report changing database dynamic problem w

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=15461
Printed Date: 04 May 2025 at 12:15am


Topic: Crystal Report changing database dynamic problem w
Posted By: CsharpCoding
Subject: Crystal Report changing database dynamic problem w
Date Posted: 26 Jan 2012 at 9:08am

I am using SQL Server 2005 and Visual Studio 2008, Cryst Reports Engine 10.5.3700.0

In the datasource for the report is a stored procedure with a schema name
(myschema.spGetResults)
When linking the report with the database expert it all works fine and CrystReport
recognizes the schema with the included stored procedure

To have the same application work with different databases we do dynamic linking
to the server and database connected at that moment.
The database structure for the database are the same only the name and the data
differs for the different databases.

When dynamic linking to the original db it all works fine.
When dynamic linking to other database it cannot find the stored procedure
Debugging shows that the CrystalReports.Engine.Table has the name available without the
schema qualifier. This make the report fail
It is proven by making a wrapper in the dbo schema. The dbo.spGetResults calls the
fully qualified name including the schema and the report can dynamically link to the
different database.

This workaround works but we need to make wrapper stored procedures for every sp
used in the report and sub reports

Is it possible to change the server, database and use the schema from the original reportTable,
it is known by CrystalReport

Just adding the schema to table.Location changes the location but does not make the report work

Please any suggestion or is it a limitation to the versions of database, dev environment or CrystRep engine

code :
(see Bischof book)
            CrystalDecisions.Shared.TableLogOnInfo currentTableLogOn;
            CrystalDecisions.Shared.ConnectionInfo cnCurrentConnectInfo;

            currentTableLogOn = new CrystalDecisions.Shared.TableLogOnInfo();
            cnCurrentConnectInfo = new CrystalDecisions.Shared.ConnectionInfo();

            cnCurrentConnectInfo.ServerName = "myserver";
            cnCurrentConnectInfo.DatabaseName = "myDatabase_1";
            //cnCurrentConnectInfo.DatabaseName = "myDatabse_2";
            cnCurrentConnectInfo.IntegratedSecurity = true;

            CrystalDecisions.CrystalReports.Engine.Tables tablesReport;

            tablesReport = crReport.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table reportTable in tablesReport)
            {
                currentTableLogOn = reportTable.LogOnInfo;
                currentTableLogOn.ConnectionInfo = cnCurrentConnectInfo;
                reportTable.ApplyLogOnInfo(currentTableLogOn);
                System.Diagnostics.Debug.Print(reportTable.Name);
            }




Print Page | Close Window