Code: Select all
Unable to cast object of type 'Stimulsoft.Report.Dictionary.StiVirtualSource' to type 'Stimulsoft.Report.Dictionary.StiSqlSource'.
System.InvalidCastException: Unable to cast object of type 'Stimulsoft.Report.Dictionary.StiVirtualSource' to type 'Stimulsoft.Report.Dictionary.StiSqlSource'.
Code: Select all
StiReport report = new StiReport();
report.Load(filename);
if (report != null) {
reportTitle.Text = report.ReportName;
StiSqlDatabase db = (StiSqlDatabase)report.Dictionary.Databases[0];
db.ConnectionString = dbConnector.GetConnectionString();
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(db);
foreach (StiDataSource ds in report.Dictionary.DataSources) {
//((StiSqlSource)report.Dictionary.DataSources["SqlSourceName"]).CommandTimeout = 6000;
((StiSqlSource)ds).CommandTimeout = 120;
}
webViewer.Report = report;
}
I suspect that the code that is failing is this:
Code: Select all
foreach (StiDataSource ds in report.Dictionary.DataSources) {
//((StiSqlSource)report.Dictionary.DataSources["SqlSourceName"]).CommandTimeout = 6000;
((StiSqlSource)ds).CommandTimeout = 120;
}