Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Crystal Report changing database dynamic problem w Post Reply Post New Topic
Author Message
CsharpCoding
Newbie
Newbie


Joined: 26 Jan 2012
Location: Netherlands
Online Status: Offline
Posts: 4
Quote CsharpCoding Replybullet Topic: Crystal Report changing database dynamic problem w
    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);
            }

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.016 seconds.