繁体   English   中英

在 .NET 中连接到 SQL Server 时,指定的网络名称不再可用

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

我重新安装了我的主要工作电脑,但在 5 个月后没有重新安装 Visual Studio。 现在我做了并开始了我的旧项目,现在它没有运行。

连接到 SQL Server 时出现超时错误,因此我增加了连接字符串中的超时,现在出现错误:

[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

在其他搜索中,我看到有人说只是重新启动 Visual Studio 并重新编译。 我这样做了,甚至重新启动,同样的错误。

我可以使用 Management Studio 连接到数据库并运行查询,所以我认为问题不在于数据库服务器本身。 也许某种防火墙?

作为参考,该错误仅在执行 sqlConn.Open() 时出现,因此没有运行查询。 另外,这是我的连接字符串:

<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"/>

这是由于网络连接间歇性丢失。 找不到网络名称错误。

在我看来,98% 的肯定,因为我最近有同样的经历,这是服务器提供商的网络问题。

例如:如果您从 Ionos 租用服务器,默认情况下所有远程连接都会被阻止,即使您禁用了服务器中的防火墙。 您仍然无法远程连接。 但是,您可以毫无问题地在服务器上进行工作。

要远程连接,您必须联系服务器提供商。 他们将解释如何从您的控制面板启用防火墙端口。

我联系了我的服务器提供商,因为我几乎感到沮丧。 这是他们的回应。

在此处输入图片说明

而且,哇!! 每个允许的客户端都可以远程连接到服务器。

祝你成功。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM