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?
sqlConnection.Open();
should be wrapped in atry{} catch(Exception e){}
in case of a bad login/timeout etc. – Kingcraft