Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specified network name no longer available when connecting to SQL Server in .NET

I reinstalled my main work pc, but didn't reinstall visual studio after 5 months. Now i did and started my old project, and now it doesn't run.

I get a timeout error when connecting to SQL Server, so i increased the timeout in the connectionstring and now i get the error:

[Win32Exception (0x80004005): The specified network name is no longer available]

[SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)]
   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) +1004
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +798
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +722
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +449
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +108
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +935
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +143
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +17
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +139
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +367
   System.Data.SqlClient.SqlConnection.Open() +130
   RRHHComprobantePago.comprobante_pago.Page_Load(Object sender, EventArgs e) in c:\Users\fleon\Documents\Visual Studio 2015\WebSites\RRHHComprobantePago\comprobante_pago.aspx.cs:47
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +85
   System.Web.UI.Control.OnLoad(EventArgs e) +79
   System.Web.UI.Control.LoadRecursive() +130
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2832

On other searches, i saw people that said just to restart visual studio and recompile. I did that, even rebooted, same error.

I can use Management Studio to connect to the database and run queries, so i don't think the issue is in the database server itself. Maybe some kind of firewall?

For reference, the error appears just when doing sqlConn.Open(), so there is no query running. Also, here is my connection string:

<add name="adamConnectionString" providerName="System.Data.SqlClient" connectionString="Initial Catalog=adam;Data Source=192.168.xxx.xxx;uid=user;pwd=password;Integrated Security=false;Connection Timeout=3000000"/>
like image 624
fjleon Avatar asked Jun 29 '16 13:06

fjleon


People also ask

Why is my SQL server not connecting?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.

Why “the specified network name is no longer available “?

If the device you’re trying to access supports SMB 1.0 (Server Message Block), but the system doesn’t support SMB 1.0, you would encounter error “ The specified network name is no longer available “. On computer running Windows 10, SMB 1.0 is probably the cause, as SMB 1.0 is no installed by default in Windows 10 latest version.

How do I troubleshoot SQL server connection issues?

Be sure and test the hosts file by pinging the SQL box from the app server via a command line. Or, alternately create a DSN with the ODBC Administrator within Control Panel and test the connection there. Implement a longer command timeout value for the application connection strings connecting to the SQL Server. This is not a database issue.

How to resolve the SQL Server Name problem?

That way, the SQL Server name will be resolved by the hosts file until you can find the real problem for what's going on with name resolution. Be sure and test the hosts file by pinging the SQL box from the app server via a command line.

Why am I getting a network name found error?

It is due to the network connection getting lost intermittently. No network name found error. Show activity on this post. In my opinion, 98% sure, because I recently had the same experience, it is a network issue from the server provider.


Video Answer


1 Answers

It is due to the network connection getting lost intermittently. No network name found error.

like image 170
user11731216 Avatar answered Oct 04 '22 21:10

user11731216