EnumAvailableSqlServers returns empty list

2019-02-27 11:07发布

I have a strange situation where i have added a reference to

Microsoft.SqlServer.Smo Microsoft.SqlServer.ConnectionInfo Microsoft.SqlServer.Management.Sdk.Sfc

and a call to SmoApplication.EnumAvailableSqlServers returns a DataTable of available servers, when it is run on my development machine.

When I deploy to my colleague's machine, the DataTable is returned empty.

Strangely, the following

        Dim server As New Microsoft.SqlServer.Management.Smo.Server("localhost\sqlexpress")
        For Each db In server.Databases
            DoSomething(db.name)
        Next

Does return the installed databases on both machines.

I have been using the simplest deployment, i.e. copying the \bin\Release directory. I suspected there is a missing assembly on the other machine, but the fact that the databases are returned on both machines contradicts that, maybe.

Ideas?

1条回答
Anthone
2楼-- · 2019-02-27 11:43

I also had the same issue. I resolved it by starting the SQL Server Browser service. http://msdn.microsoft.com/en-us/library/ms165734(v=sql.90).aspx

查看更多
登录 后发表回答