Cómo obtener la cadena de conexión de App.Config en C #
[csharp]
<!–?xml version="1.0" encoding="utf-8"?–>
<configuration>
<system.data>
<dbproviderfactories>
<remove invariant="MySql.Data.MySqlClient"></remove>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></add></dbproviderfactories>
</system.data>
<appsettings>
<add key="UsuarioDesde" value="Yo"></add>
</appsettings>
<connectionstrings>
<!– MYSQL SERVER –>
<add name="MYSQL_MiConexion" connectionstring="datasource=MiServidor;port=3306;username=MiUsuarioBD;password=MiClaveBD;database=MiBaseDatos;" providername="MySql.Data.MySqlClient"></add>
</connectionstrings>
</configuration>
[/csharp]
[csharp]
using System;
using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;
[/csharp]
[csharp]
private MySqlConnection connection;
connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["MYSQL_MiConexion"].ConnectionString);
[/csharp]