Error making MySQL connection using .NET. How to solve?

2

Exception when connecting to bank:

  IsPasswordExpired: 'conn.IsPasswordExpired' threw an exception of type 'System.NullReferenceException'

     

ServerThread: 'conn.ServerThread' threw an exception of type 'System.NullReferenceException'

     

ServerVersion: 'conn.ServerVersion' threw an exception of type 'System.NullReferenceException'

Exception while trying to open connection:

  

"The type initializer for   'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception. "

public static MySqlConnection Conexao()
{
   string strConexao = "Server=ip_do servidor_de bd;Port=3306;Database=meubanco;Uid=usuario;Pwd=senha;";
   MySqlConnection conn = new MySqlConnection();
   conn = new MySqlConnection(strConexao);

   conn.Open();

   return conn;
}
    
asked by anonymous 16.11.2017 / 15:04

0 answers