web-dev-qa-db-fra.com

Une erreur liée au réseau ou à une instance spécifique s'est produite lors de l'établissement d'une connexion à SQL Server

J'ai déployé mon application Web asp.net sur somee.com. Chaque fois que je me connecte à ce site (ipc.somee.com), une erreur liée au réseau, telle que:

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
25
Suresh

Sql Server déclenche cette erreur lorsque votre application ne dispose pas de suffisamment de droits pour accéder à la base de données. il y a plusieurs raisons à propos de cette erreur. Pour corriger cette erreur, vous devez suivre les instructions suivantes.

  1. Essayez de connecter le serveur SQL à partir de votre serveur à l'aide du studio de gestion. Si vous utilisez l'authentification Windows pour vous connecter au serveur SQL, définissez l'identité de votre pool d'applications sur administrateur du serveur.

  2. si vous utilisez l'authentification SQL Server, vérifiez votre chaîne de connexion dans web.config de votre application Web et définissez l'ID utilisateur et le mot de passe du serveur SQL pour vous permettre de vous connecter.

  3. si votre base de données se trouve sur un autre serveur (base de données distante d'accès), activez tout d'abord l'accès à distance de la propriété de serveur SQL Server de SQL Server à partir du studio de gestion de serveur SQL, puis activez le gestionnaire de configuration TCP/IP de serveur SQL de forme.

  4. après avoir fait toutes ces choses et que vous ne pouvez toujours pas accéder à la base de données, vérifiez ensuite le pare-feu du formulaire serveur et ajoutez une règle au pare-feu pour activer le port du serveur SQL (par défaut, utilisez 1433, pour vérifier port du serveur SQL, vous devez vérifier le port TCP/IP du protocole réseau du gestionnaire de configuration du serveur SQL).

  5. si votre serveur SQL s'exécute sur une instance nommée, vous devez écrire le numéro de port avec le nom du sereur SQL, par exemple 117.312.21.21/nameofsqlserver,1433.

  6. Si vous utilisez un hébergement en nuage comme Amazon aws ou Microsoft Azure, le serveur ou l'instance s'exécutera derrière le pare-feu du cloud. Vous devez donc activer le port 1433 dans le pare-feu du cloud si vous disposez d'une instance par défaut ou d'un port spécifique pour le serveur SQL pour l'instance nommée.

  7. Si vous utilisez Amazon RDS ou SQL Azure, vous devez activer le port du groupe de sécurité de cette instance.

  8. Si vous accédez au serveur SQL via le mode d'authentification du serveur SQL, assurez-vous d'avoir activé la propriété "SQL Server et mode d'authentification Windows" de l'instance de serveur SQL. enter image description here

    1. Redémarrez votre instance de serveur SQL après toute modification de la propriété, car certaines modifications nécessiteront un redémarrage.

si vous rencontrez des difficultés supplémentaires, vous devez fournir davantage d'informations sur votre site Web et votre serveur SQL.

45
Hiren Dhaduk