I found that SMO sometimes does not return the correct list of available SQL servers.
1. I have SQL development installed in my machine. When I use SMO to retrieve list of server, it does not return anything. But when I use "OSQL -L" command, it returns (local) server.
This is my code.
Cursor.Current = Cursors.WaitCursor
cmbServerName.Items.Clear()
Dim dtSQLServers As DataTable = SmoApplication.EnumAvailableSqlServers()
Dim I As Integer
For I = 0 To dtSQLServers.Rows.Count - 1
Dim ServerName As String = dtSQLServers.Rows(I)("Server").ToString()
If (dtSQLServers.Rows(I)("Instance") IsNot Nothing And dtSQLServers.Rows(I)("Instance").ToString().Length > 0) Then
ServerName = ServerName + "\" + dtSQLServers.Rows(I)("Instance").ToString()
cmbServerName.Items.Add(ServerName)
End If
Next I
Cursor.Current = Cursors.Default
2. When I install SQL 2005 Express in any machine, I cannot retreive its existance via SMO with the same code (on local and remote machine).
Anyone experiencing this situation before? Is there something wrong in my code? How can I fix this?
Thank you,
Hi,consider the differences with Server and InstanceName, I once wrote an Article about that:
http://sqlserver2005.de/Articles/1/
I saw that you wanted to add the data of ServerName to instance name which would be wrong in your case.
2. Is SQL Server brwoser running ? Otherwise it could be that instances running on other server can′t be retrieved if hosted on different ports.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
No comments:
Post a Comment