【问题标题】:Can't connect to sqlserver无法连接到sqlserver
【发布时间】:2013-02-12 11:02:15
【问题描述】:

我正在尝试在远程 sql 服务器上安装 asp.net 会员系统,但出现此错误:

设置失败。

例外: 无法连接到 SQL Server 数据库。


失败详情

System.Web.HttpException (0x80004005): Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.) ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
ClientConnectionId:24557c63-f9b1-498c-bd1d-0d678f29f795
   at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
   at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
   at System.Web.Management.ConfirmPanel.Execute()

我从 vs2012 连接到远程 sql server 时遇到同样的问题

【问题讨论】:

  • 您是如何尝试连接到远程 SQL Server 的?通过代码,还是 Management Studio??
  • 我可以通过 SQL SERVER Management Studio 快速连接到远程实例,但是当我尝试通过 Visual Studio 连接到它或使用 aspnet_regsql 时,它给了我上述错误
  • 如果将连接字符串添加到web.config,然后通过代码建立连接呢??
  • 发现问题,是外部应用程序干扰连接造成的,“互联网下载管理器”,我卸载了应用程序,然后一切顺利。
  • @Mahdi:请将您的解决方案作为答案发布,以便其他面临相同问题的人快速看到可能的解决方案。理想情况下,还要说明您如何发现外部应用程序正在干扰。 (其他访问者可能不希望在 cmets 部分找到答案,因此永远看不到您的解决方案。)

标签: asp.net sql-server database-connection


【解决方案1】:

如果以下一种或多种情况为真,则可能会出现此问题:

  • SQL Server 未配置为接受远程连接。
  • SQL Server 的必要协议未在 SQL Server 计算机或运行 BizTalk Server 的 SQL Server 客户端计算机上启用。

按照以下步骤可能会解决此问题:

  • SQL Server 外围应用配置工具在 SQL Server 2008 上不可用。要在 SQL Server 2008 计算机上为 SQL Server 启用远程连接,请按照 SQL Server 2008 联机中的说明进行操作帮助。

  • 使用 SQL Server 配置管理器 工具在 SQL Server 计算机上启用 TCP/IP 和/或 命名管道 协议。

    1. 单击开始,指向所有程序,然后单击SQL Server 配置管理器

    2. 单击展开SQL Server 网络配置,然后单击MSSQLSERVER 协议

    3. 右键单击 TCP/IP 协议,然后单击启用

    4. 右键单击命名管道协议,然后单击启用

    5. 关闭 SQL Server 配置管理器工具。

  • 使用 SQL Server 配置管理器 工具在 SQL Server 客户端计算机上启用 TCP/IP 和/或 命名管道 协议正在运行 BizTalk Server。

    1. 单击开始,指向所有程序,然后单击SQL Server 配置管理器

    2. 点击展开SQL Server网络配置,然后点击ClientProtocols

    3. 右键单击 TCP/IP 协议,然后单击启用

    4. 右键单击命名管道协议,然后单击启用

    5. 关闭 SQL Server 配置管理器工具。

注意:确保运行 BizTalk Server 的 SQL Server 客户端计算机上的至少一种协议与 SQL Server 计算机上启用的协议相匹配。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-04
    • 2021-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多