title: C# connecting to another database in the same server
body: <p>We are working on a system that requires us to connect to another database, but all the databases are in the same server.  As for now we are connected to the server but with only our own database connected, and it's in a separate class.  Which we then call in the main program, so right now I'm trying to figure out how do i connect to another database? We are also using phpmyadmin to edit the databases.</p>
  
  <p>This one is the class to connect to the database and server:</p>
  
  <pre><code> public DatabaseConnection()
              {
                  HOST = "server";
                  DB = "DB1"; //our database
                  UID = "user";
                  PASSWD = "password";
              }
  
              public override string ToString()
              {
                  string connectionstring;
  
                  connectionstring = "SERVER=" + HOST + ";DATABASE=" +
                  DB + ";" + "UID=" + UID + ";" + "PASSWORD=" + PASSWD + ";";
  
                  return connectionstring;
              }
  </code></pre>
  
  <p>This one is the one to connect in the main class:</p>
  
  <pre><code> public void connect()
          {
              mySQLconnection = new MySqlConnection(dbInfo.ToString());
              try
              {
                  mySQLconnection.Open();
                  this.Text = "[Connected]";
                  populateCliendinformation();
              }
              catch (Exception e)
              {
                  this.Text = "Problem";
                  MessageBox.Show(e.Message);
              }
          }
  </code></pre>