473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Reusing connection strings in config files?

Jen
..NET 2.0 introduced the <connectionStrings> section in .config files,
but how do I reuse the connection strings defined under
<connectionStrings> in other parts of the config files?

<connectionStrings>
<add name="connStr1" .../>
</connectionStrings>

Now I want to reuse the connection string defined by the name
"connStr1" in 25 other places in the same configuration file by
referencing the "connStr1" name instead of hard-coding the same
connection string 25 times. How do I do this? (I know how they can be
referenced using ConfigurationManager programmatically. This is WITHIN
the same config file, non-programattically.)

Jun 14 '06 #1
1 1771
Jen,
Sorry but this simply "does not compute". If you already have it in one
place, why on earth do you need to have it in 25 more places? A config file
is nothing but an xml document - a text file. It has no "internal
programmatic awareness" of itself.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jen" wrote:
..NET 2.0 introduced the <connectionStrings> section in .config files,
but how do I reuse the connection strings defined under
<connectionStrings> in other parts of the config files?

<connectionStrings>
<add name="connStr1" .../>
</connectionStrings>

Now I want to reuse the connection string defined by the name
"connStr1" in 25 other places in the same configuration file by
referencing the "connStr1" name instead of hard-coding the same
connection string 25 times. How do I do this? (I know how they can be
referenced using ConfigurationManager programmatically. This is WITHIN
the same config file, non-programattically.)

Jun 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: stewart | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the...
14
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review,...
3
by: ad | last post by:
I have a web application and a class library in a solution. The class library is make of typed datasets, and include many Table in it. The connection strings of the TableAdapters is come from...
4
by: Matt Colegrove | last post by:
I'm working on a web app that is published to a hosting service. I'm developing it on my local PC with VS 2005 and SQL Express. The hosting service DB is SQL Server 2000. I have two...
2
by: =?Utf-8?B?U2JhdGNodQ==?= | last post by:
How will i read connection strings in all web.config files in one particualr machine?
2
by: Mike P | last post by:
I've always put my connection strings in the web.config, but I've just recently seen an example of a connection string in a resource file. What are the advantages of doing this, and could you do it...
11
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Is there a way in ASP.NET 2.0 to have different connection strings settings in a web.config files that are dynamically used based upon the server that the web application is running on? For...
9
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.