views:

53

answers:

2

I know I just missing something simple, but when I try pulling the connection string from the ConfigurationManager, I always get null.

I have System.configuration added as a reference

In the source file I have

using System.Configuration;
using MySql.Data;
using MySql.Data.MySqlClient;
....
_connStr = ConfigurationManager.ConnectionStrings["MySqlDataConnection"].ConnectionString;
objConnection = new MySqlConnection(_connStr);

where in my app config I have...

<configuration>
  <connectionStrings>
    <add name="MySqlDataConnection"
       connectionString="server=127.0.0.1;database=HLSDB;uid=me;password=myPasswd;pooling=false;"
       providerName="MySql.Data.SqlClient"/>
  </connectionStrings>
</configuration>
A: 

Please double-check that your configuration file is deployed as MyApplication.exe.config (and not app.config) in the output directory. That code you have posted is fine.

Kieren Johnstone
A: 

Maybe you could try

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

To verify you are looking at the correct config file.

TooFat