Learn how to a build a cloud-first strategyRegister Now


How do you know which ConnectionString is currently in use?

Posted on 2009-12-29
Medium Priority
Last Modified: 2013-12-17
How do you know which ConnectionString is currently in use in the appConfig? I'm using C# .NET 2005 Windows Forms. Thanks in advance.
Question by:0nepiece
  • 2
LVL 42

Accepted Solution

Meir Rivkin earned 200 total points
ID: 26138469
to grab connection string from app.config
use the following:
-add dll reference System.Configuration

foreach (ConnectionStringSettings con in ConfigurationManager.ConnectionStrings)
                string conStr = con.ConnectionString;

u want to know what is the connection string currently used by whom?
if u use SqlConnection for example, or any other connection object u can investigate the instance which is used.


Author Comment

ID: 26138613
Umm, the connection string currently used by the application / the 'active' connection? Is there like a flag saying that the a particular connection string is being used by the application?
LVL 11

Expert Comment

ID: 26138901
there's not really such thing as an "active connection" in your app.config: it's just an XML file storing configuration values. Meaning that it all depends on what your application is doing with those values :)

Author Closing Comment

ID: 31670795
Ok got that. Thanks!

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

810 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