This is a migrated thread and some comments may be shown as answers.

second sqldatasource won't connect

1 Answer 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robert Lampe
Top achievements
Rank 1
Robert Lampe asked on 16 Jul 2010, 08:42 AM
Hi,

I've added two datasources to my report project. the first one is for the report itself, the second one for a chart.
Please see the code below.

<connectionStrings>
   <add name="ReportPlugin.Properties.Settings.Development"
connectionString="Data Source=*****;Initial Catalog=*****;Integrated Security=True"
       providerName="System.Data.SqlClient" />
 </connectionStrings>


//
// sqlDataSource1
//
this.sqlDataSource1.ConnectionString = "ReportPlugin.Properties.Settings.Development";
this.sqlDataSource1.Name = "sqlDataSource1";
this.sqlDataSource1.SelectCommand = resources.GetString("sqlDataSource1.SelectCommand");
//
// sqlDataSource2
//
this.sqlDataSource2.ConnectionString = "ReportPlugin.Properties.Settings.Development";
this.sqlDataSource2.Name = "sqlDataSource2";
this.sqlDataSource2.Parameters.AddRange(new Telerik.Reporting.SqlDataSourceParameter[] {
new Telerik.Reporting.SqlDataSourceParameter("country.id", System.Data.DbType.Int32, "=Parameters.CountryId.Value")});
this.sqlDataSource2.SelectCommand = resources.GetString("sqlDataSource2.SelectCommand");

private void chart1_NeedDataSource(object sender, EventArgs e)
{
    Telerik.Reporting.Processing.Chart chart = sender as Telerik.Reporting.Processing.Chart;
    chart.DataSource = sqlDataSource2;
}

The first datasource connects perfectly. The second doesn't. They make use of the same ConnectionString.
The error is:
An error has occurred while processing Chart 'chart1':
Unable to connect to database. Please verify that your connection string is valid; in case you use a 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.

Any ideas?

Thnx,
Robert

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 20 Jul 2010, 06:32 AM
Hi Robert Lampe,

Unfortunately this is a known limitation related to the Designer's preview if you set a datasource component in a NeedDataSource event. If you run the report in a report viewer the report will be working as expected.

We noticed that you are using the event only for setting a datasource thus our suggestion would be to set a DataSource through the Chart's property grid.

Sincerely yours,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Robert Lampe
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or