title: Determine which connection to use
body: <p>In my code, if I have multiple connection string, how can I achieve that without create another ExecuteNonQuery() shared function because of the multiple connection? I thinking of using if else to determine whether a class function call ExecuteNonQuery() should use particular connection string for open/close connection, I want to reuse the ExecuteNonQuery() ever have different connection, any better idea? Or if the design are wrong?     </p>
  
  <pre><code>public void OpenConnection()
  {
      try
      {
          string strSQLSvr = ConfigurationManager.ConnectionStrings["SQLConnStr"].ConnectionString;
          string strUsrSvr = ConfigurationManager.ConnectionStrings["usrMaint"].ConnectionString;
  
          conn = new SqlConnection(strSQLSvr);
          conn.Open();
      }
      catch (Exception ex)
      {
      }
  }
  
  public void CloseConnection()
  {
      try {
          if (conn.State == ConnectionState.Open)
          {
              conn.Close();
          }
      }
      catch (Exception ex)
      {
  
      }
  
  public void ExecuteNonQuery(string strSQL)
  {
      try
      {
          OpenConnection();
          cmd.CommandText = strSQL;
          cmd.Connection = conn;
          cmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
  
      }
      finally
      {
          CloseConnection();
      }
  }
  </code></pre>