Marcin
Marcin

Reputation: 1203

ASP.NET error "Could not connect to SQL Server"

I have an application deployed in separate website on dedicated port (path: https://server:8085/service). It works. Now I want to deploy it under new IIS application (path https://server/newapp/service). The problem is that I'm getting error that the app is unable to connect to sql server. The app pool is the same and both the site and the application point to the same folder on disk.

[Win32Exception (0x80004005): Unable to find the specified file]

[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.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +642 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1079 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +6605639 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) +233 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278 System.Data.SqlClient.SqlConnection.Open() +239 System.Web.SessionState.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval) +309

[HttpException (0x80004005): Unable to connect to SQL Server session database.] System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection conn, Exception e) +3539419 System.Web.SessionState.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval) +3533255 System.Web.SessionState.SqlSessionStateStore.GetConnection(String id, Boolean& usePooling) +500 System.Web.SessionState.SqlSessionStateStore.ResetItemTimeout(HttpContext context, String id) +78 System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +707 System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12335126 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

Upvotes: 0

Views: 763

Answers (2)

Cato
Cato

Reputation: 3701

Right click on the desktop and 'create new document' then change the .txt extension to .udl, then you can enter the SQL server credentials and 'Test Connection'

my bet is the SQL server is not accessible have you

'Verify that the instance name is correct and that SQL Server is configured to allow remote connections.'

Upvotes: 0

Harish Nayak
Harish Nayak

Reputation: 348

Please check the configuration file and you should also check for access privileges for the application and sqlserver.

Upvotes: 1

Related Questions