Sql.SqlDataSourceEnumerator不适用于FrameWork 4.6 [英] Sql.SqlDataSourceEnumerator doesn't work with FrameWork 4.6

查看:83
本文介绍了Sql.SqlDataSourceEnumerator不适用于FrameWork 4.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,最近我不得不为Windows 10创建一个应用程序。知道操作系统可以使用框架4.6,我必须为VS2013安装此版本。我的应用程序运行完美,除了类SqlDataSourceEnumerator!我有一个小表单,在启动时,它在本地计算机和网络上找到所有未隐藏的SQL Server实例....以防万一,您已找到解决此问题的方法,或者您想建议另一种方式,我在这里跟着你。谢谢。



这里我的代码:



Private Sub SearchSQLServerInstance()

试试

Dim listOfServers As New List(Of String)()

Dim sqlEnumerator As Sql.SqlDataSourceEnumerator = Sql.SqlDataSourceEnumerator.Instance

sqlEnumerator.GetDataSources ()



Dim sqlServersTable As DataTable = sqlEnumerator.GetDataSources()



For Each rowOfData As DataRow In sqlServersTable.Rows

FrmSplashScreen.Refresh()

Dim serverName As String = rowOfData(ServerName)。ToString()

Dim instanceName As String = rowOfData(InstanceName)。ToString()

'检查实例名称是否为空

如果不是instanceName.Equals(String.Empty)那么

serverName + = String。格式(\ {0},instanceName)

结束如果

'

listOfServers.Add(serverName&|&rowOfData (3).ToString)

FrmSplashScreen.Refresh()

下一页

'

'

如果不是listOfServers什么都没有那么

listOfServers.Sort()

Dim i As Integer = Nothing

'

For i = 0 to listOfServers.Count - 1

FrmSplashScreen.Refresh()

Dim NomeServerSplit()As String = Split(listOfServers(i), |)

Dim NomeServer As String = NomeServerSplit(0).ToString.TrimEnd

'

Me.ComboBoxInstance.Items.Add(NomeServerSplit (0).ToString.TrimEnd)

Me.ComboBox Version.Items.Add(NomeServerSplit(1).ToString.TrimEnd)

FrmSplashScreen.Refresh()

下一页

结束如果

Catch ex As Exception

MsgBox(Err.Description,MsgBoxStyle.Critical,搜索SQL服务器实例)

结束尝试



感谢您的关注...

Hello everyone, recently I had to create an application for Windows 10. Knowing the OS works with framework 4.6, I had to install this version for VS2013. My application works perfectly, except Class SqlDataSourceEnumerator! I had a small form and when start, it find all not hidden instances of SQL Server on the local machine and on the network ....Just in case, you have found a solution for this problem or you like to suggest another way, I'm here to follow you. Thank you.

Here my code :

Private Sub SearchSQLServerInstance()
Try
Dim listOfServers As New List(Of String)()
Dim sqlEnumerator As Sql.SqlDataSourceEnumerator = Sql.SqlDataSourceEnumerator.Instance
sqlEnumerator.GetDataSources()

Dim sqlServersTable As DataTable = sqlEnumerator.GetDataSources()

For Each rowOfData As DataRow In sqlServersTable.Rows
FrmSplashScreen.Refresh()
Dim serverName As String = rowOfData("ServerName").ToString()
Dim instanceName As String = rowOfData("InstanceName").ToString()
'check if the instance name is empty
If Not instanceName.Equals(String.Empty) Then
serverName += String.Format("\{0}", instanceName)
End If
'
listOfServers.Add(serverName & "|" & rowOfData(3).ToString)
FrmSplashScreen.Refresh()
Next
'
'
If Not listOfServers Is Nothing Then
listOfServers.Sort()
Dim i As Integer = Nothing
'
For i = 0 To listOfServers.Count - 1
FrmSplashScreen.Refresh()
Dim NomeServerSplit() As String = Split(listOfServers(i), "|")
Dim NomeServer As String = NomeServerSplit(0).ToString.TrimEnd
'
Me.ComboBoxInstance.Items.Add(NomeServerSplit(0).ToString.TrimEnd)
Me.ComboBoxVersion.Items.Add(NomeServerSplit(1).ToString.TrimEnd)
FrmSplashScreen.Refresh()
Next
End If
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "Search SQL Servers Instances")
End Try

Thank You for you attention...

推荐答案

阅读此主题



http://www.dotnethell.it/Forum/messages.aspx?ThreadID=47143
Read this thread

http://www.dotnethell.it/Forum/messages.aspx?ThreadID=47143


这篇关于Sql.SqlDataSourceEnumerator不适用于FrameWork 4.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆