0

Using Windows 10 Pro and VS2015 Pro with all updates at the time of writing. Ran VS in safe mode and repair install of Visual Studio with no luck. Note that SSMS and other apps can access the database OK at any time.

The code can be reduced to open a SQL database connection;

Dim sqlCon As New SqlConnection("Server=server\instance;Database=database;User Id=…;Password=…")
sqlCon.Open()
'Works after reboot as many times as required but fails after build or rebuild!
Console.WriteLine(“Connection Opened”)  
sqlCon.Close()
sqlCon.Dispose()

The error after rebuild is;

Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. 
Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
ajayel
  • 3,027
  • 2
  • 26
  • 33
  • I suppose that it's a network related problem. The SQL Server service is set to "Automatic" start? Maybe is it set to "Delayed starting"? – Igor Damiani Aug 29 '16 at 15:50

1 Answers1

0

Turns out our IT team had installed Bitdefender Endpoint Security Tools on the PC. Fortunately it was straightforward for a suitable firewall profile to be added to the in-house Bitdefender management server.

ajayel
  • 3,027
  • 2
  • 26
  • 33