Click here to Skip to main content
15,907,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
For my organization, I have developed database web application (ASP.net C#) where the backend database is SQL server.
I recently got ownership of Web server in my organization where I am going to host the application on intranet.
Before deploying the actual application on web server, I thought I have to create test application with SQL database for testing.
I have deployed the test application on web server. but when I am trying to access the application getting error when trying to access page where the gridview with SQL server table is added.
Details of error is as follow.
Is I am missing something?
Need you expertise to guide on this error.





C#
Server Error in '/' Application.

Access is denied 
  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.ComponentModel.Win32Exception: Access is denied

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: 



[Win32Exception (0x80004005): Access is denied]

[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6564850
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +6590016
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +219
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6592502
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6592983
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +878
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1162
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +72
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +6596173
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +103
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2102
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1079
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6600667
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +233
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278
   System.Data.SqlClient.SqlConnection.Open() +239
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +292
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +420
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +277
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +3319735
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +28
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +313
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +146
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +192
   System.Web.UI.Control.EnsureChildControls() +189
   System.Web.UI.Control.PreRenderRecursiveInternal() +60
   System.Web.UI.Control.PreRenderRecursiveInternal() +222
   System.Web.UI.Control.PreRenderRecursiveInternal() +222
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4297

  


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009 


What I have tried:

I have deployed the test application on web server. but when I am trying to access the application getting error when trying to access page where the gridview with SQL server table is added.
Details of error is as follow.
Is I am missing something?
Need you expertise to guide on this error.
Posted
Updated 17-Feb-16 18:00pm

Exception due to your web application is not able to connect SQLSERVER instance. Following are options to resolve the problem:

1. Check if your service is running up

Go to All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services
Check to make sure SQL Server service status is Running.

or

Open run command console(Windows + R) then type services.msc. You will all services in your system and check SqlServer (Sqlexpress) service is running mode.

2. Make sure your database engine is configured to accept remote connections

Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
Click on Surface Area Configuration for Services and Connections
Select the instance that is having a problem > Database Engine > Remote Connections
Enable local and remote connections
Restart instance using services.msc in run command window(discussed in #1)

3. Enable TCP/IP in SQL Server Configuration

Go to All Programs >> Microsoft SQL Server 2012 > Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP

Right Click on TCP/IP >> Click on Enable

Then restart the sqlserver service using services.msc in run command window(discussed in #1)

Lastly you need to check that it might be server firewall setting because sometimes firewall blocks incoming request from other servers. And also check you are providing correct connection string means username, password, server etc..
 
Share this answer
 
v5
Comments
Member 12256084 17-Feb-16 1:19am    
Hi,
Thank you for reply.
just to clarify that, I am having only Database access of SQL server in my organization. SQL server administrator created database for my application on SQL server.
Since I can only able to connect SQL server from Visual Studio
[no name] 17-Feb-16 1:29am    
You should able to connect SQLServer from where the web application is hosted. Means try to access the sql server from your webserver. Just follow the answer. Ask your admin everything is fine from SQLServer side.
Member 12256084 17-Feb-16 2:50am    
Hi Again
I have just test the connection to SQL server from web server and the error message popup is "SQL Server does not exist or access denied." where as I have tried to connect with SQL server from my local system and the connection is succeeded.
Now I am not sure why the connection is failed from Web Server?
[no name] 17-Feb-16 4:17am    
Did you go through answer to check where your problem is? Just check with all options where you are missed.
Member 12256084 17-Feb-16 4:49am    
FYI, SQL server is installed on different machine and I don't have access of it, I am having only ownership of Web server.
run this update:
asp_net_regiis.exe
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900