My app needs to support multiple SQL server databases (DB1, DB2, DB3....) on different physical servers Server 1 and Server 2. How can I configure the web.config and create the database connection string at runtime when I comet to know the database. I am
using data access application block. Do I need to create different <instances> and <connectionStrings> to every instance ? How do I make a connection with the instances mentioned in the web.config in C# ??
We are using similar techniques on most of our projects. If you are using .Net 2.0, then you can define multiple connection strings in it with different name. Lets say with each computer name a connection string is associated.
When you create a database instance using DAAB, you have to pass an instance name which actually is your connection string name. Here you can implement a check which first gets current machine name and then pass that as instance name parameter to create
database call.
Thank you for you answer. However it doesn't solve my purpose. Each of the servers have approx 200 databases. With this approach I will have to have 200 + 200 connection string in web.config.
Is it possible to use the EntLib function CreateDatabase and specify the connection string there ? I can pass the connection string from the UI to the DAL.
None
0 Points
5 Posts
EntLib Connectionstring Runtime using DAAB
Dec 15, 2007 12:09 PM|marcus80|LINK
My app needs to support multiple SQL server databases (DB1, DB2, DB3....) on different physical servers Server 1 and Server 2. How can I configure the web.config and create the database connection string at runtime when I comet to know the database. I am using data access application block. Do I need to create different <instances> and <connectionStrings> to every instance ? How do I make a connection with the instances mentioned in the web.config in C# ??
Thanks in advance
marcus
Enterprise Library 2.0- Exception Handing Block Enterprise Library 2.0 Introduction "Enterprise Library 2.0" configSections Enterprise Library 2.0- Logging Application Block Enterprise Library Patterns & Practices Enterprise Library medium trust Enterprise Library 3.1 ConfigurationSource
Participant
1590 Points
366 Posts
Re: EntLib Connectionstring Runtime using DAAB
Dec 17, 2007 02:19 AM|ziqbalbh|LINK
Hi,
We are using similar techniques on most of our projects. If you are using .Net 2.0, then you can define multiple connection strings in it with different name. Lets say with each computer name a connection string is associated.
When you create a database instance using DAAB, you have to pass an instance name which actually is your connection string name. Here you can implement a check which first gets current machine name and then pass that as instance name parameter to create database call.
http://ziqbalbh.com
** Please mark as ANSWER if my reply helped you
None
0 Points
5 Posts
Re: EntLib Connectionstring Runtime using DAAB
Dec 17, 2007 12:56 PM|marcus80|LINK
Thank you for you answer. However it doesn't solve my purpose. Each of the servers have approx 200 databases. With this approach I will have to have 200 + 200 connection string in web.config.
Is it possible to use the EntLib function CreateDatabase and specify the connection string there ? I can pass the connection string from the UI to the DAL.
Thank you in advance.
None
0 Points
7 Posts
Re: EntLib Connectionstring Runtime using DAAB
Apr 14, 2008 08:11 AM|jarchambault|LINK
You can add the connection string to your configuration manager like this: