Report designer creates crystal report in designer with direct connection to database with ODBC (DSN) connection. Same reports are executed via a Winform(C#) application via DSN and provides Database Server, database, user ID and password.
I need to make such changes to the Crystal Report object. ReportDocument should not directly connect to Database via DSN. Instead, we will bring data via service by calling respective stored procedure and parameters as System.Data.DataTable
. This DataTable
object should be used to populate/generate reports.
I do get the stored procedure and parameter information from ReportDocument.DataBase.Tables[I].Location
and ReportDocument.DataDefinition
object respectively. After setting DataSource with ReportDocument.DataBase.Tables[I].SetDataSource(DataTable)
, it still ask for database/server and user credential to connect to server.
Can we achieve scenario and populate report with in-memory table instead of direct connection to database over ODBC?
Two things you need to focus on:
Scenario 1: Same server and database name
In this case you need to provide the credentials using
SetDatabaseLogon
method as followsScenario 2: Different server OR database name
In this case you need to provide the credentials using
ApplyLogOnInfo
methodNotes: If you have any sub reports, you need to apply
SetDatabaseLogon
and/orApplyLogOnInfo
to all the sub reports and their tables respectively.UPDATE:
Applying ApplyLogOnInfo to subreports