C# connect to database and list the databases [duplicate]
Possible Duplicate: SQL Server query to find all current database names I am trying to figure out how to list the databases after connecting to the servers without specifying a database first. sqlConnection1 = new SqlConnection("Server=" + sqlServer + ";Database=" + database + ";User ID=" + userName + ";Password=" + password + ";Trusted_Connection=False;"); 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. Ideas? You can use SqlConnection.GetSchema : using(var con = new SqlConnection(