How do you know which ConnectionString is currently in use?

Posted on 2009-12-29
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
    LVL 42

    Accepted Solution

    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

    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

    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

    Ok got that. Thanks!

    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

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    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.…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 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

    21 Experts available now in Live!

    Get 1:1 Help Now