Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql server 2008 express with advanced services
Message
From
24/08/2008 08:31:49
 
 
To
All
General information
Forum:
ASP.NET
Category:
Databases
Title:
Sql server 2008 express with advanced services
Miscellaneous
Thread ID:
01341366
Message ID:
01341366
Views:
69
Since yesterday available for download: https://www.microsoft.com/express/sql/download/default.aspx

Good news. The sql management objects are faster.
The code below (connecting to an instance and listing its databases) takes 10-12 sec with sql server 2005 and about half a sec with sql server 2008
/*
There are 3 dlls to add to the references.  They are commented in the using statements
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// microsoft.sqlserver.smo.dll
using Microsoft.SqlServer.Management.Smo;

// microsoft.sqlserver.connectioninfo.dll
// Microsoft.SqlServer.Management.Sdk.Sfc.dll
using Microsoft.SqlServer.Management.Common;

namespace GregoryAdam.Test
{
   public class SqlServerSmoTest
    {
        public static void ConnectTest()
        {
            Server server = new Server();

            server.ConnectionContext.ServerInstance = @"ComputerName\SQLEXPRESS";
            server.ConnectionContext.LoginSecure = false;
            server.ConnectionContext.Login = "Id";
            server.ConnectionContext.Password = "passwd";

            Console.WriteLine("InstanceName {0}", server.InstanceName);
            foreach (Database db in server.Databases)
            {
                Console.WriteLine(" Name: {0} #Connections={1}", db.Name, db.ActiveConnections);
                foreach (FileGroup fg in db.FileGroups)
                {
                    foreach (DataFile df in fg.Files)
                    {
                        Console.WriteLine(" File: {0} ", df.FileName);
                    }
                }
                Console.WriteLine();

            }
        }
    }
}
Gregory
Reply
Map
View

Click here to load this message in the networking platform