First of all: everything you will read in this post happens only if Windows 10 April 2018 update is installed. No problem before installation and after update uninstallation.
After installing Windows 10 1803 update, all my VB program (VB6, .NET and WPF) running from network mapped drive or UNC path can't connect to SQL server, no problem if the same executable is placed and executed from local drive (tested on 2 pc in the same network):
This is the error (maybe not significat to solve this problem):
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).
Simple VB.NET code to reproduce the problem (place the code in a simple form with a button in the button_click event, set values to connect to the SQL server, compile, save the exe file on a network path and execute it):
Dim myConnectionString As String
Dim mySqlConnectionStringBuilder As New SqlConnectionStringBuilder()
mySqlConnectionStringBuilder.DataSource = myServer
mySqlConnectionStringBuilder.InitialCatalog = myDatabase
mySqlConnectionStringBuilder.UserID = myUtente
mySqlConnectionStringBuilder.Password = myPassword
myConnectionString = mySqlConnectionStringBuilder.ConnectionString
Dim mySqlConnection As New SqlConnection(myConnectionString)
mySqlConnection.Open() <- error
Exception:
System.Data.SqlClient.SqlException (0x80131904): Si è verificato un errore di rete o specifico dell'istanza mentre si cercava di stabilire una connessione con SQL Server. Il server non è stato trovato o non è accessibile. Verificare che il nome dell'istanza sia corretto e che SQL Server sia configurato in modo da consentire connessioni remote. (provider: SQL Network Interfaces, error: 26 - Errore nell'individuazione del server/dell'istanza specificata)
in System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
in System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
in System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.Open()
in RiepilogoOreTimer.RiepilogoOreTimerWindow.ConnessioneOK()
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-1,State:0,Class:20
Any ideas?
Update: If I uninstall the April 2018 update the issue go away and the program works fine even if executed on a network drive, but this can't be the solution...
Update 08/05/2018: I noticed that April 2018 update brought some changes in security:
Windows 10, version 1803 provides additional protections:
- New Attack surface reduction rules
- Controlled folder access can now block disk sectors
Could it be the cause of the issue? I'm not a security manager so I can't say if this can cause my problem
Update 09/05/2018: I found this information in this post:
Windows 10 update 1803 does not open network connections on executables files on SMBv1 share (as Windows Server 2003)
but I don't know what SMBv1 is... somebody can help me?
Check the TCP/IP and Named Pipes protocols and port. Open SQL Server Configuration Manager and check the SQL Server Network Configuration protocols. You should enable Named Pipes and TCP/IP protocol. For the TCP/IP protocol, right click and select properties to check the TCP/IP communication port as well.
Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.
Make sure to enter correct SQL Server instance name while making database connection otherwise you will face sql error 53. Try to connect using ip address and port number instead of putting server name in connection string. Make sure SQL Server services are running fine and its accessible. Check firewall details.
Finally I found the problem: in the server with the shared folder, SMBv2 is disabled (I don't know why) so only SMBv1 is active; the same program executed from the same client in the same network but located on a server with SMBv2 enabled works fine.
So the problem is about SMBv1 share, deprecated starting from Windows 10 1803
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With