?
Solved

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

Posted on 2013-01-25
2
Medium Priority
?
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Assisted Solution

by:Srinivasulu Muppala
Srinivasulu Muppala earned 750 total points
ID: 38820373
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 750 total points
ID: 38825958
<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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

762 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