Last post May 30, 2011 12:56 AM by 6233114
Apr 26, 2011 09:47 PM|MasterPepsi|LINK
I'm trying to configure a development and testing environment on my home computer. I just installed a brand new copy of Windows 7 Pro 64-bit, I'm using the latest versions of SQL Server Express, Visual Web Developer, and IIS.
I'm unable to get my ASP.Net application to connect to a local SQLServer database. I am able to Add Connection and succesfully Test Connection within Visual Web Developer, as well as execute queries. But as soon as I try to open a connection to the database
during application runtime, I get the following error:
Server Error in '/' Application.
Cannot open database "datafort" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
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: Cannot open database "datafort" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
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.
[SqlException (0x80131904): Cannot open database "datafort" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +6277312
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1363
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +6292062
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6291977
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +352
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +831
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +49
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6293782
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +78
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1922
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +89
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6296606
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) +312
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +3375159
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +28
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4185
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
I've searched for solutions, but everything I've tried thus far has not worked. I've followed the recommendations in this thread: http://forums.asp.net/p/1558691/3841648.aspx
None of those solutions worked. I tried running osql, but I wasn't able to successfully run the scripts (I've never heard of or used osql prior to reading that thread). I tried enabling the Mixed Mode Security, but that had no impact because I'm using Windows
I'm new to ASP.Net and SQL Server, so it's entirely possible that I'm missing something. What am I doing wrong?
Apr 27, 2011 05:18 AM|raduenuca|LINK
Well the error is self explanatory. The user that connects to your SQL Server Express instance has no rights to do so. You several options:
- In SQL Server create a Windows Authentication Login for the user IIS APPPOOL\ASP.NET v4.0 and give him rights to access your database
- Use an already existing login and set is as the user in your Application Pool
- Use SQL Server Authentication instead of Windows Authentication to connect to your database. In this case you need a SQL Login and you need to set the user and password in the connectionstring (in your web.config file)
Apr 27, 2011 03:20 PM|MasterPepsi|LINK
Hi raduenuca, thanks for the information. I will try those solutions when I get off work.
I have almost the exact same setup on a laptop, but everything just seemed to work "out of the box." I didn't have to create a login for "IIS APPPOOL\ASP.NET v4.0".
Is it possible that this problem is caused by incorrectly configuring SQL Server Express during the installation process? (Maybe I screwed something up with the Service Account or Authentication Mode during the install?)
Thanks for your help!
Apr 27, 2011 09:10 PM|MasterPepsi|LINK
Thanks again raduenuca.
I created a Windows Authentication user with the name IIS APPPOOL\ASP.NET v4.0 and gave him the appropriate rights. That worked.
Still curious why I didn't have this problem on my laptop. Anyway, simple solution for a simple problem. Thanks!
May 30, 2011 12:56 AM|6233114|LINK
I have the same issue and its been 3 days now.
How did you create a Windows Authentication Login for the user IIS APPPOOL ?
Like what were the steps you used?