TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ken Barrett
NA
123
0
retrieving the connection string from the app.config file
Jul 31 2009 4:22 PM
I want to retrieve the DB connection string from the app.config file.
Here is my app.config file :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="dbConnection"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\HREChk.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Question 1 ) How do I pull this out? I want dbConnection connectionString. This ought to be simple, but the document is driving me nuts.
Question 2 ) You will note that part of the path for the connectionString contains "|DataDirectory|" (obviously a variable, maybe and ENV variable), where is this stored and how is it expanded?
TIA Ken
ETA: edited in Firefox.
Reply
Answers (
4
)
Inheriting from dynamically loaded library
how to divide application in panels?