Solved

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

Posted on 2013-01-25
2
328 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
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 250 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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 article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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