How to Get List of Database using SMO object

Krv
Posted by Krv under C# category on | Points: 40 | Views : 1374
//namespace
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;

//Code
 sqlserver.ConnectionContext.LoginSecure = false;
sqlserver.ConnectionContext.Login = sa;
sqlserver.ConnectionContext.Password = test;
}
sqlserver.ConnectionContext.Connect();

foreach (Database db in sqlserver.Databases)
{
console.writeline(db.Name);
}

Comments or Responses

Login to post response