枚举 SQL Server 2008 集群上的数据库
我们的 IT 部门最近从数据库迁移到集群。这一举措破坏了许多使用以下代码枚举数据库的旧应用程序:
Dim objConn As ServerConnection
objConn = New ServerConnection()
If Me.ComboServers.Text.Trim.Length() > 0 Then
objConn.ServerInstance = Me.ComboServers.Text.Trim()
End If
Me.SMOServer = New Server(objConn)
Me.ComboDatabases.Items.Clear()
For Each objDB As Database In Me.SMOServer.Databases
Me.ComboDatabases.Items.Add(objDB.Name)
Next
此代码在连接到独立数据库时运行良好,但无法连接到 SQL 集群上的命名实例。
如何枚举 SQL 集群上命名实例上的数据库?
Our IT department recently moved from our databases to a cluster. This move broke many legacy applications that enumerate the databases with the following code:
Dim objConn As ServerConnection
objConn = New ServerConnection()
If Me.ComboServers.Text.Trim.Length() > 0 Then
objConn.ServerInstance = Me.ComboServers.Text.Trim()
End If
Me.SMOServer = New Server(objConn)
Me.ComboDatabases.Items.Clear()
For Each objDB As Database In Me.SMOServer.Databases
Me.ComboDatabases.Items.Add(objDB.Name)
Next
This code works well enough when connecting to a standalone database but will not connect to a named instance on a SQL cluster.
How can I enumerate the databases on a named instance on a SQL cluster?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
命名实例的发现依赖于 SQL Server Browser Service。群集上的 SQL 浏览器服务和 Windows 防火墙存在一个已知问题。请参阅无法连接到群集上的 SQL Server 命名实例。需要应用操作系统和 SQL 本身的特定更新,有关详细信息,请参阅链接的文章。一个好的解决方法是使用静态端口并在连接字符串中显式指定侦听端口。
Discovery of named instances relies on SQL Server Browser Service. There is a known issue with the SQL Browser service and Windows Firewall that occurs on clusters. See Unable to connect to a SQL Server named instance on a cluster. There are specific updates to OS and SQL itself required to be applied, see the linked article for details. A good workaround is to use static ports and explicitly specify the listening port in the connection string(s).