2

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?

GilShalit
  • 6,175
  • 9
  • 47
  • 68
  • you gotta explain a bit more, if in both machines you get a referenc to the instance of SQL Express running in the localhost this only tells you in both machine SQL Express is installed, what other server or instance string are you using to query againts when it does not work? Is the SQL Server you are looking for on the network and how do you get it from the machine where it works? – Davide Piras Sep 18 '11 at 12:44

1 Answers1

4

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

  • +1 this is entirely possible. The SQL Server Browser Service is resposible for making the local instance "discoverable". This is also true, if both the app that calls `EnumAvailableSqlServers()` and the desired database (here a local SQL Express instance), are located on the same computer. – Christian.K Jan 23 '12 at 07:16