我試圖填充組合框與陣列的所有其他元素的所有其他價值得到字符串數組
數組包含這樣
(0) server
(0) sqlInstance
(1) server
(1) sqlInstance
(2) server
(2) sqlInstance
我要添加的所有SQLINSTANCE值數據到組合框。不知道如何做,除了可能是另一個陣列。
感謝
Private Sub GetSQLServers()
Dim oSQLApp As New SQLDMO.Application
Dim oServerNames As SQLDMO.NameList
Dim strServer As String
Dim ServerArr() As String
oServerNames = oSQLApp.ListAvailableSQLServers()
For i = 0 To oServerNames.Count
strServer = (oServerNames(i))
ServerArr = strServer.Split("\")
txtSQLHost.Text = ServerArr(0)
For Each s As String In ServerArr
'value of server instance
cbxSQLServerNames.Items.Add(s)
Next
Next i
End Sub
這是工作,我敢肯定它是不是
組合框與sqlInstances僅 的txtbox有服務器
oServerNames是填充的最好方式server \ sqlInstance
Private Sub GetSQLServers()
Dim oSQLApp As New SQLDMO.Application
Dim oServerNames As SQLDMO.NameList
Dim strServer As String
Dim ServerArr() As String
Dim sn As Integer = 1
oServerNames = oSQLApp.ListAvailableSQLServers()
For i = 0 To oServerNames.Count
strServer = (oServerNames(i))
ServerArr = strServer.Split("\")
txtSQLHost.Text = ServerArr(0)
For Each s As String In ServerArr
'value of server instance
If ((sn Mod 2) = 0) Then
cbxSQLServerNames.Items.Add(s)
sn = sn + 1
Else
sn = sn + 1
End If
Next
Next i
End Sub
使用此選項現在.. 感謝
Private Sub GetSQLServers()
Dim oSQLApp As New SQLDMO.Application
Dim oServerNames As SQLDMO.NameList
Dim strServer As String
Dim ServerArr() As String
oServerNames = oSQLApp.ListAvailableSQLServers()
For i = 0 To oServerNames.Count
strServer = (oServerNames(i))
ServerArr = strServer.Split("\")
txtSQLHost.Text = ServerArr(0)
For Each item In oServerNames
Dim parts = item.Split("\")
Dim instance = parts(1)
cbxSQLServerNames.Items.Add(instance)
Next
Next i
End Sub
使用列表(類),數組的:缺少的東西在這裏...
如果數組是這樣的:
你可以這樣做那麼無論你想要什麼,你都可以發佈你想要的任何元素。 – Plutonix