Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql server 2008 express with advanced services
Message
De
24/08/2008 08:31:49
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Titre:
Sql server 2008 express with advanced services
Divers
Thread ID:
01341366
Message ID:
01341366
Vues:
70
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
Répondre
Fil
Voir

Click here to load this message in the networking platform