Reusing connection strings in config files?

J

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.)
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top