日期:2014-05-17  浏览次数:20481 次

【MSSQL2008--SMO错误】
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management;



namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ServerConnection sc = new ServerConnection("(local)", "sa", "123456");
            sc.LoginSecure = false;
            sc.Login = "sa";
            sc.Password = "123456";
            Console.WriteLine("DatabaseCount:" + "win");

        }
    }
}

上面的代码是成功的

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management;



namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Server s = new Server("POOFLY-PC");
            ServerConnection sc = s.ConnectionContext;
            sc.LoginSecure = false;
            sc.Login = "sa";
            sc.Password = "123456";

            Database db = new Database(s, "newdb");
            db.Create();
            //ServerConnection sc = new ServerConnection("(local)", "sa", "123456");
            //sc.LoginSecure = false;
            //sc.Login = "sa";
            //sc.Password = "123456";
            //Console.WriteLine("DatabaseCount:" + "win");

        }
    }
}

这个就错误了。。。

C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"e:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll" /reference:"e:\Program Files\Microsoft SQL Se