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

Report with multi-tenant database

3 Answers 241 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gerald Toh
Top achievements
Rank 1
Gerald Toh asked on 05 Oct 2011, 07:53 AM

Hi All,

I have a multi-tenant database based on Microsoft SQL Azure to store my client info and I am using Telerik Report to for my Report modules.

Since I have to pull info from different database for different client, how do i dynamically configure my connection at web.config in order to know which database am i pulling from?

Please advise
Thanks You.

Eg.

<connectionStrings>

    <add name="ReportClassLib.Properties.Settings.ClientDB" connectionString="**;Initial Catalog=DB_1;User ID=**;Password=**"

            providerName="System.Data.SqlClient" />

</connectionStrings>

Client 1 is DB_1, Client 2 is DB_2,……

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 10 Oct 2011, 10:15 AM
Hi Susan Foo,

Do you want to get the connection or you want to change the report connectionString based on the current client?

If the first you can directly access the connectionString in the report constructor as shown in the following code snippet:

System.Configuration.ConfigurationManager.ConnectionStrings["ReportClassLib.Properties.Settings.ClientDB"].ConnectionString
More information on this topic is available in this KB article: Using connectionStrings from configuration file

If you want to modify the connectionString based on the current client check out the following forum thread. Regards,
Peter
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Gerald Toh
Top achievements
Rank 1
answered on 14 Oct 2011, 07:53 AM
Hi Peter,

Thanks for you reply,
Actually the second solution is what i needed,

public string ConnectionString
{
    set
    {
        this.sqlDataSource1.ConnectionString = value;
    }
}

var report = new ReportDynamicConnectionString();
report.ConnectionString = @"Data Source=.\SQLEXPRESS2008;Initial Catalog=AdventureWorks;Integrated Security=True";
this.ReportViewer1.Report = report;

But my problem is ReportDynamicConnectionString()
how do we define this class?

Thanks and Regards,
Lvin Low
0
IvanDT
Telerik team
answered on 19 Oct 2011, 09:37 AM
Hello Susan,

The ReportDynamicConnectionString is a report class with the ConnectionString property. We define and initialize the Report(var report = new ReportDynamicConnectionString()) and after that applying the new connection string.

Greetings,
IvanDT
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Gerald Toh
Top achievements
Rank 1
Answers by
Peter
Telerik team
Gerald Toh
Top achievements
Rank 1
IvanDT
Telerik team
Share this question
or