Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
retrieving the connection string from the app.config file
Ken Barrett
Jul 31 2009 4:22 PM
16.5k
Reply
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
apostraphe SQLexception
Advanced Sql to Dataset query