How do you know which ConnectionString is currently in use?

How do you know which ConnectionString is currently in use in the appConfig? I'm using C# .NET 2005 Windows Forms. Thanks in advance.
Who is Participating?
Meir RivkinFull stack Software EngineerCommented:
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.

0nepieceAuthor Commented:
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?
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 :)
0nepieceAuthor Commented:
Ok got that. Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.