I have a Crystal Reports 2008 report with dynamic parameters (e.g Distribution point which are referring to a column DP.distributionPoint). When opening the report in my application (C#) I am setting the datasource at run time and report opens properly and on the Enter Parameter Values window for report shows available values for distribution point (DP.distributionPoint).
Code I am using to set datasource dynamically (note there is no subreport for this report, but report is referring to database tables and views from the database)
SetDataSource(ReportDocument report, string serverName, string databaseName)
{
// Set the connection for the main report.
report.DataSourceConnections[0].SetConnection(serverName, databaseName, true);
TableLogOnInfo tableLogonInfo = new TableLogOnInfo();
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = databaseName;
connectionInfo.ServerName = serverName;
connectionInfo.IntegratedSecurity = true;
foreach (Table table in report.Database.Tables)
{
tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
table.Location = tableLogonInfo.ConnectionInfo.DatabaseName + ".dbo." + table.Location.Substring(table.Location.LastIndexOf(".") + 1);
}
}
I need to set datasource every time I open the report, which is a time consuming process in case of a large report. My plan is to set datasource on the report and save the report with location information, so next time I need not to call set datasource.
But when I test the application without setdatasource, I can open the report but Available Values for Distribution point in ‘Enter Parameter Values’ window is not showing now.
Note:
I have checked the table.LogOnInfo.ConnectionInfo.ServerName and table.LogOnInfo.ConnectionInfo.DatabaseName for all the tables/views in the report it is same as the database I am connecting to.
If I set set table.Location I can view Available Values List.
Questions:
Why available values list not showing when I open the report without setdatasource function?
Is it possible to change/control the available values for FieldParameter programmatically in Crystal Reports 2008?
Message was edited by: Ludek Uher
Message was edited by: Ludek Uher