我重新安装了我的主要工作电脑,但 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"/>
最佳答案
这是由于网络连接时断时续。 找不到网络名称错误。
关于c# - 在 .NET 中连接到 SQL Server 时指定的网络名称不再可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38101393/