title: if SqlConnection C# Check Connection open , close
body: <p>My code not want to return close connection.
  I'm not able to use them if I do not have much knowledge.</p>
  
  <pre><code> private void button1_Click(object sender, EventArgs e)
      {
          string connectionString = GetCString();
  
          using (SqlConnection connection = new SqlConnection(connectionString))
  
  
              if (connection.State == ConnectionState.Open)
              {
                  connection.Open();
                  Logger.getS().info_warning("Conexão Sucedida");
                  Logger.getS().info_warning("DataSource : " + connection.DataSource);
                  Logger.getS().info_warning("Banco De Dados : " + connection.Database);
                  Logger.getS().info_warning("Versão do SQL : " + connection.ServerVersion);
                  Logger.getS().info_warning("Status : " + connection.State);
  
                  {
  
                  }
  
              }
                else
                {
  
                    Logger.getS().info_erro("SqlConnection Não foi possivel connectar.");
                    Logger.getS().info_erro(" Status da Conexão : " + connection.State);
  
  
                }
  
          }
  </code></pre>