如何使用SMO的任何解决方法连接到SQLServer2008的已经做?

编程入门 行业动态 更新时间:2024-10-25 00:31:59
本文介绍了如何使用SMO的任何解决方法连接到SQLServer2008的已经做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写这篇查找本地计算机上的SQL Server实例:

I wrote this for finding the sql server instances on the local machine:

using System; using System.Data; using Microsoft.SqlServer.Management.Smo; namespace Application3 { class Program { static void Main(string[] args) { string srvname = string.Empty; string srvnames = null; DataTable dt = SmoApplication.EnumAvailableSqlServers(true); Console.WriteLine("------------->" + dt.Rows.Count); foreach (DataRow dr in dt.Rows) { try{ Console.WriteLine("-->Instance " + dr["name"]); Server srv = new Server((string)dr["name"]); foreach (Database db in srv.Databases) Console.WriteLine(db.Name); }catch(Exception e) { Console.writeLine(e.toString()); } } } }

我有3个实例,在我的本地机器

I have 3 instances in my local machine

  • rk2k3-VM-SR(SQL2008实例)
  • rk2k3-VM-SR \ sql2k8ex preSS(sql2k8 instacne)
  • rk2k3-VM-SR \ sqlex preSS(sql2k5实例)
  • 但它是仅示出2和3 1不显示。当我连接使用服务器对象失败的sql2k8ex preSS。

    But it is only showing 2 and 3. 1 does not show. And when I connect using server object it fails for sql2k8express.

    下面是输出....


    - >实例RK2K3-VM-SR \ SQLEX $ P $干燥综合征   主   模型   MSDB   tempdb中

    -->Instance RK2K3-VM-SR\SQLEXPRESS master model msdb tempdb


    - >实例RK2K3-VM-SR \ SQL2K8EX $ P $干燥综合征

    -->Instance RK2K3-VM-SR\SQL2K8EXPRESS

    Microsoft.SqlServer.Management.Common.ConnectionFailureException:未能conn将   等服务器RK2K3-VM-SR \ SQL2K8EX $ P $干燥综合征。 ---> Microsoft.SqlServer.Management.Com   不支持此SQL Server版本(10.0):mon.ConnectionFailureException。      在Microsoft.SqlServer.Management.Common.ConnectionManager.CheckServerVersion   (ServerVersion版)      在Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect(无线   ndowsIdentity impersonatedIdentity)      在Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()      ---内部异常堆栈跟踪的结尾---      在Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()      在Microsoft.SqlServer.Management.Common.ConnectionManager.PoolConnect()      在Microsoft.SqlServer.Management.Common.ConnectionManager.get_ServerVersion(   )      在Microsoft.SqlServer.Management.Smo.ExecutionManager.get_ServerVersion()      在Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetDbComparer(布尔樱雪   rver)      在Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitializeStringComparer()      在Microsoft.SqlServer.Management.Smo.AbstractCollectionBase.get_StringCompar   ER()      在Microsoft.SqlServer.Management.Smo.SimpleObjectCollectionBase.InitInnerCol   经文()      在Microsoft.SqlServer.Management.Smo.SmoCollectionBase.get_InternalStorage()      在Microsoft.SqlServer.Management.Smo.SmoCollectionBase.InitializeChildCollec   化(布尔刷新)      在Microsoft.SqlServer.Management.Smo.SmoCollectionBase.GetEnumerator()      在ConsoleApplication3.Program.Main(字串[] args)在C:\ Documents和设置搜索   GS \ Administrator.APP \桌面\ ConsoleApplication3 \的Program.cs:行25

    Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to conn ect to server RK2K3-VM-SR\SQL2K8EXPRESS. ---> Microsoft.SqlServer.Management.Com mon.ConnectionFailureException: This SQL Server version (10.0) is not supported. at Microsoft.SqlServer.Management.Common.ConnectionManager.CheckServerVersion (ServerVersion version) at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect(Wi ndowsIdentity impersonatedIdentity) at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect() --- End of inner exception stack trace --- at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect() at Microsoft.SqlServer.Management.Common.ConnectionManager.PoolConnect() at Microsoft.SqlServer.Management.Common.ConnectionManager.get_ServerVersion( ) at Microsoft.SqlServer.Management.Smo.ExecutionManager.get_ServerVersion() at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetDbComparer(Boolean inSe rver) at Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitializeStringComparer() at Microsoft.SqlServer.Management.Smo.AbstractCollectionBase.get_StringCompar er() at Microsoft.SqlServer.Management.Smo.SimpleObjectCollectionBase.InitInnerCol lection() at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.get_InternalStorage() at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.InitializeChildCollec tion(Boolean refresh) at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.GetEnumerator() at ConsoleApplication3.Program.Main(String[] args) in C:\Documents and Settin gs\Administrator.APP\Desktop\ConsoleApplication3\Program.cs:line 25

    我怎样才能解决这个问题?我的系统的防火墙被禁用,所有的SQL服务正在运行。

    How can i fix this? My System firewall is disabled and all sql services are running.

    推荐答案

    这是code previously为SQL 2005写的? 如果是的话,你需要

    Is this code previously written for SQL 2005? If yes you need to

  • 本机上的SQL 2008 +管理对象安装SQL 2005向后兼容性包。 (www.microsoft/downloads/details.aspx?FamilyID=b33d2c78-1059-4ce2-b80d-2343c099bcb4&displaylang=en)

    删除引用到2005年SLQ和放大器的SDK DLL文件;再参考SQL 2008年SK的DLL。 ( msdn.microsoft/en-us/library/ms162129。 ASPX )

    Remove references to SDK dlls of SLQ 2005 & re reference to SK Dlls of SQL 2008. (msdn.microsoft/en-us/library/ms162129.aspx)

    重建。

    另请参考:stackoverflow/questions/1067818/application-cannot-find-microsoft-sqlserver-smo-on-sql-2008-machine

  • 更多推荐

    如何使用SMO的任何解决方法连接到SQLServer2008的已经做?

    本文发布于:2023-05-28 12:33:19,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/320994.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:词库加载错误:Could not find file 'D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!