Getting Connection String?

I found the code (at the bottom) as a way to fish the connection string out of the config file. However, despite

using System.Configuration;

I cannot find these references--e.g. ConnectionStringSettings -- in System.Configuration. I find only

System.Configuration.ClientSettingsSection

System.Configuration.ConfigurationException

System.Configuration.ConfigurationSettings

System.Configuration.ConfigXmlDocument

Where is ConnectionStringSettings What am I missing

Thx, jess

http://msdn2.microsoft.com/en-us/library/z0kbht2d(en-US,VS.80).aspx

or

ConnectionStringSettings settings = ConfigurationSettings.ConnectionStrings[name];

DbProviderFactory factory = DbProviderFactories.GetFactory (settings.ProviderName);

DbConnection datasetConx = factory.CreateConnection();

datasetConx.ConnectionString = settings.ConnectionString;




Answer this question

Getting Connection String?

  • KatyTX

    Me, neither. Duh. I write VB2005 but found the answer here. Thanks!

  • mmikedm1000

    Uh, no, I didn't. Thx!

    sheepishly,

    Jess



  • Jr.Coder

    Did you add the assembly "System.Configuration" as a reference to your application

    It is not enough just to add a using statement, you also need to reference the assembly by:

    1) Right clicking on References

    2) Choosing "Add Reference..."

    3) Selecting "System.Configuration" from the .NET tab.

    Once you do that things should start to come into place.

    Regards,

    Dave



  • Getting Connection String?