title: C# connect to database and list the databases
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/873393/sql-server-query-to-find-all-current-database-names">SQL Server query to find all current database names</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to figure out how to list the databases after connecting to the servers without specifying a database first.  </p>
  
  <pre><code>sqlConnection1 = new SqlConnection("Server=" + sqlServer + ";Database=" + database +    
  ";User ID=" + userName + ";Password=" + password + ";Trusted_Connection=False;");
  </code></pre>
  
  <p>So basically what i want is the end user to connect to the sql server, then have a drop down list populated with the list of db's they can connect and query.</p>
  
  <p>Ideas?</p>