title: How do you connect to a DataBase from a ComboBox?
body: <p>Connection string file in <code>app.config</code>:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name ="test1" connectionString = "Data Source=
                (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=1521)))
                (CONNECT_DATA=(SERVICE_NAME=test1)));User Id=test1;Password=test1;" /&gt;
  
      &lt;add name ="test2" connectionString = "Data Source=
                (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=1521)))
                (CONNECT_DATA=(SERVICE_NAME=test1)));User Id=test2;Password=test2;" /&gt;
      &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>File in <code>Form</code> loading:<br></p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();           
      }
  
      static string conString = ConfigurationManager.ConnectionStrings["test1"].ConnectionString;
      OracleConnection con = new OracleConnection(conString);
      OracleCommandBuilder cmdbld;
      OracleDataAdapter da;
      DataSet ds;
  
  
      private void button1_Click(object sender, EventArgs e)
      {
          //Load Data
          try
          {
              con.Open();
              da = new OracleDataAdapter("sql command", con);
              ds = new DataSet();
              cmdbld = new OracleCommandBuilder(da);
              da.Fill(ds);
              dataGridView1.DataSource = ds.Tables[0];
          }
  
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
          finally
          {
              con.Close();
          }
      }
  }
  </code></pre>
  
  <p>So, how do I use a <code>ComboBox</code> to change connection between <code>test1</code> and <code>test2</code> here?<br>
  Right now, I only replace <code>test1</code> to <code>test2</code> but putting <code>comboBox1.Text</code> in <code>connectionStrings[]</code> doesn't work. What can I do here?</p>
  
  <p>I can make another log in form and make one form for test1 and the other for <code>test2</code> connection but it seems very inefficient way to switch between server. </p>