J
j-in-uk
Can i get a list of sql databases by just connecting to the server
programmatically
string myConnString = "Integrated Security=SSPI;Initial
Catalog={0};Data Source=" + serverName +";";
SqlConnection cn = new SqlConnection(myConnString);
cn.Open();
SqlDataReader dr = (new SqlCommand("sp_databases",
cn)).ExecuteReader();
while (dr.Read())
{
lstDatabases.Items.Add(dr["DATABASE_NAME"]);
}
This does not work cos I don't know the name of database/initial
catalog at this point
programmatically
string myConnString = "Integrated Security=SSPI;Initial
Catalog={0};Data Source=" + serverName +";";
SqlConnection cn = new SqlConnection(myConnString);
cn.Open();
SqlDataReader dr = (new SqlCommand("sp_databases",
cn)).ExecuteReader();
while (dr.Read())
{
lstDatabases.Items.Add(dr["DATABASE_NAME"]);
}
This does not work cos I don't know the name of database/initial
catalog at this point