问题
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:
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
来源:https://stackoverflow.com/questions/7460567/enumavailablesqlservers-returns-empty-list