How do I access my connectionstring from app.config in 2008?

I am trying to read my connectionstring from app.config in 2008. I followed some instructions and this is how far I got:
1) typed this in my app.config:
    <add key="localstring" value="data source=(local);initial catalog=tempdb;Integrated    Security=SSPI;"/>
2) declare outside my Data class:
Imports System.Configuration
3) then
in my function inside my Data class I typed:
and I did not get "configurationmanager" , it's not available
Do I need to setup something else in my program
please help
Who is Participating?
Chad SmithConnect With a Mentor Software EngineerCommented:
You need to set a reference to System.Configuration.dll
Did you add a reference to System.Configuration?
Also, I am not sure if this happens in 2008, but when I have done something similar in 2005 if I use the Imports System.Configuration I have issues.  I am not sure why that is, but in the past I have add the referecne and then typed the full namespace out to get to app settings.
Below are the steps you have to do.

1. Add Reference to a dll, "System.Configuration"
2. Use below code to get the connection string value.

sample web config in VS 2008 is given below

    <add name="test" connectionString="my connection string"/>
pachecositaAuthor Commented:
You rock!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.