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);
}