Solved

How to get the connection information from machine.config file ?

Posted on 2013-01-25
2
325 Views
Last Modified: 2013-02-10
i am developing windows applicaiton using visul studio 2005 c#. The project not having app.config file.
Connection string information is avilable in machine.config file. How do i read the connection string from machine.config file ?
0
Comment
Question by:Varshini S
2 Comments
 
LVL 4

Assisted Solution

by:Srinivasulu Muppala
Srinivasulu Muppala earned 250 total points
Comment Utility
Nice question, i found exact artical for your req.
please  check in url:  http://www.codeproject.com/Articles/127892/Shared-Application-Settings-in-machine-config
0
 
LVL 10

Accepted Solution

by:
Monica P earned 250 total points
Comment Utility
<connectionStrings>
                <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
        </connectionStrings>

Open in new window


read values

 Configuration machineConfig = ConfigurationManager.OpenMachineConfiguration();
            foreach (ConnectionStringSettings connectionstring in machineConfig.ConnectionStrings.ConnectionStrings)
            {
                // u can have multiple connection strings
            }

Open in new window

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now