I'm enumerating all databases of an SQL Server 2005 instance using SMO like as shown below and it returns a non existing database (it was existing in the past).
Using conn As SqlConnection = New SqlConnection(_connectionString)
conn.Open()
Dim smoConnection As New ServerConnection(conn)
Dim srv As Server = New Server(smoConnection)
For Each db As Database In srv.Databases
If db.Name.Contains("blablabla") Then
doStuffOnDatabase(db)
End If
Next
smoConnection.Disconnect()
End Using
On the same server, running
exec sp_databases();
returns the correct database list. I don't understand why SMO does not give me the same list as sp_databases().
The code above works correctly on customer machines. I've only seen it fail like that on two coworkers laptop running under Windows Vista.
Why is SMO returning an old no longer existing database ?
The assembly versions are all 9.0.242.0