I got two project in my solution in Visual Studio 2010.
Project 1 contains an app.config
with a ConnectionString
.
How can I access that ConnectionString
from Project 2?
Since they are both using the same ConnectionString
, I would prefer to only have one instance in my solution.
To read the connection string into your code, use the ConfigurationManager class. string connStr = ConfigurationManager. ConnectionStrings["myConnectionString"].
Connection strings can be stored as key/value pairs in the connectionStrings section of the configuration element of an application configuration file.
You can add the files as a link to the file to one of your projects.
Use Add an Existing Item
to the project you want to add the file to - the Open
button has a small down arrow, if you click that you can select Add as Link
.
This will add the file as a link from the original location, meaning you only have one physical file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With