I am setting up a Telerik Reporting Class Library in a WinForms Solution, with Telerik Reporting Q2 2011. Following the Best Practices, I am using a sqlDataSource, and have used the wizard to setup the connection and SQL statements.
The problem is that the report editor has set the connection string in the report designer file like so:
Report1.Designer.cs
It is a String of the Report Project Settings Variable, not a Reference to the Report Project Settings Variable. This works fine for designing the report within the Reports Project, however, a ReportViewer in a Forms Project will produce a run-time error.
Error Output Produced:
I have attempted to rectify the error by copying the Connection String Setting from the Report Project into the Forms Project. I assume this doesn't work as the Connection String is trying to reference the Private Connection String in the Report Project.
I now set the Connection String in the Report Constructor to the Settings Value. After this is added the Forms Project displays the report without error.
Report1.cs
I am unsure why I am required to reference the setting through the "Settings.Default" object, where the designer sets a string that references straight from the "Settings" object. (edit: the report reads the app.config file, it doesn't use the settings object)
Is there a work around so I won't need to set the connection string in the constructor as well as the designer?
The problem is that the report editor has set the connection string in the report designer file like so:
Report1.Designer.cs
this
.sqlDataSource1.ConnectionString =
"ReportsProject.Properties.Settings.ReportsConnectionString"
;
It is a String of the Report Project Settings Variable, not a Reference to the Report Project Settings Variable. This works fine for designing the report within the Reports Project, however, a ReportViewer in a Forms Project will produce a run-time error.
Error Output Produced:
- Telerik.Reporting.Processing.Data.SqlDataSourceException: Unable to establish a connection to the database. Please, verify that your connection string is valid. In case you use a named connection string from the application configuration file, make sure the name is correct and the connection string settings are present in the configuration file of your application. ---> System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
I have attempted to rectify the error by copying the Connection String Setting from the Report Project into the Forms Project. I assume this doesn't work as the Connection String is trying to reference the Private Connection String in the Report Project.
I now set the Connection String in the Report Constructor to the Settings Value. After this is added the Forms Project displays the report without error.
Report1.cs
this
.sqlDataSource1.ConnectionString = ReportsProject.Properties.Settings.Default.ReportsConnectionString;
I am unsure why I am required to reference the setting through the "Settings.Default" object, where the designer sets a string that references straight from the "Settings" object. (edit: the report reads the app.config file, it doesn't use the settings object)
Is there a work around so I won't need to set the connection string in the constructor as well as the designer?