首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >建立与SQL Server的连接时发生网络相关错误或特定于实例的错误

问建立与SQL Server的连接时发生网络相关错误或特定于实例的错误
EN

Stack Overflow用户
提问于 2013-04-28 04:23:25
回答 1查看 211.5K关注 0票数 45

我在somee.com上部署了我的asp.net web应用程序,每当我登录到这个站点(ipc.somee.com)时,它都会给我一个与网络相关的错误,比如:

代码语言:javascript
复制
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)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: 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)

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 


[SqlException (0x80131904): 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)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296071
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +920
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +434
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +5311099
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +37
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +558
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +67
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1052
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +143
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +83
   System.Data.SqlClient.SqlConnection.Open() +96
   Default.log(Object sender, EventArgs e) in c:\users\sreekanth\documents\visual studio 2010\Projects\IPCWebApp\IPCWebApp\Default.aspx.cs:43
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +124
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
EN

回答 1

Stack Overflow用户

发布于 2013-04-28 05:37:43

当您的应用程序没有足够的权限访问数据库时,Sql Server将触发此错误。这个错误有几个原因。要修复此错误,应遵循以下说明。

  1. 尝试使用management studio从您的服务器连接sql server。如果使用windows身份验证连接sql server,则将应用程序池标识设置为服务器管理员。
  2. 如果您使用sql server身份验证,请检查web应用程序的web.config中的连接字符串,并设置允许您登录的sql server的用户id和密码。TCP
  3. 如果您的数据库在其他服务器上(访问远程数据库),则首先从sql server management studio中启用对sql server的远程访问,并从sql server配置管理器中启用

/IP。

  1. 在做了所有这些事情后,你仍然无法访问数据库,然后检查你试图访问数据库的服务器形式的防火墙,并在防火墙中添加一个规则来启用sql server的端口(默认情况下,sql server使用1433,要检查sql server的端口,您需要检查sql server配置管理器的网络协议TCP/IP端口)。sql
  2. 如果你的sql server运行在命名实例上,那么你需要写下端口号和sql serer名称,例如117.312.21.21/nameofsqlserver,1433.
  3. If,你正在使用像亚马逊aws或微软azure这样的云主机,那么服务器或实例将在云防火墙后面运行,所以如果你有默认实例或命名实例的
  4. 特定端口,你需要在云防火墙中启用1433端口。如果您使用的是amazon或sure,则需要启用该实例的安全组中的端口。
  5. 如果您通过SQL server身份验证模式访问sql server,请确保您启用了"SQL Server和Windows身份验证模式“sql server实例属性。

代码语言:javascript
复制
1. Restart your sql server instance after making any changes in property as some changes will require restart.

​

如果您进一步遇到任何困难,那么您需要提供有关您的网站和sql server的更多信息。

票数 58
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16256533

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档