This sample is written in C# and use SQL Server 2005 beta 2 and a beta version of the .Net Framework 2.0. It show how, with SMO you can Connect to SQL Server 2005
In order to connect to SQL Server using SMO you have to reference the following namespace (and the corresponding assembly):
using
1) The following code allow you to connect with the intergrated security :
Server sqlserver;
conn =
conn.ServerInstance = "My Server"
conn.Connect();
sqlserver =
The object sqlserver is the object on with youe are going to work on each SMO project (to have to list of database for example).
2) The following code allow you to connect to SQL Server with the SQL Server authentification :
ServerConnection conn;
conn.ServerInstance = "My Server";
conn.Login = "My login";
conn.Password = "My Password";