Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'Philip-Desktop\Philip'

I'm been struggling to find an answer to this problem for hours now...

I use to not get this error while accessing the ASPNETDB database, but unfortunately I don't know what I changed. The error comes up when I try to access a file called Admin.aspx I have in a folder called Admin. I had restrictions set on this folder using the Web Site Administration Tool, but when the error came up I took them all of them off to see what the problem was and I still get the error?? The Admin.aspx file is the only one that gets the error..

My connection string in web.config is:

<add name="WIJLConnectionString1" connectionString="Data Source=localhost;Integrated Security=SSPI; Initial Catalog=ASPNETDB" providerName="System.Data.SqlClient" />

Here is the error:

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'Philip-Desktop\Philip'.

[SqlException (0x80131904): Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'Philip-Desktop\Philip'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009598 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +183
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +123
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +319
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1618
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75 System.Web.UI.Control.EnsureChildControls() +102 System.Web.UI.Control.PreRenderRecursiveInternal() +42 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

Someone please help!! I'm desperate at this point

like image 374
Philip906 Avatar asked Dec 22 '22 18:12

Philip906


2 Answers

The error message is as clear as it can be:

Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'Philip-Desktop\Philip'

That Windows user isn't allowed to connect to that database and use it.

Check to make sure:

  • that you have the proper server name in your connection string. Is it really localhost? Or did you perhaps install SQL Server Express and it ended up being (local)\SQLExpress instead??

  • that the server you're connecting to has a login for Philip-Desktop\Philip (check in Object Explorer -> (your server) -> Security -> Logins)

  • that the database ASPNETDB has a user based on that login so that you can use that database (check in Object Explorer -> (your server) -> Databases -> (your database) -> Security -> Users)

  • that your admin.aspx page is truly referencing that connection string you've given (WIJLConnectionString1). Is there by any chance a separate web.config in your Admin folder that e.g. has a different connection string, and the admin.aspx page references that connection string instead??

like image 198
marc_s Avatar answered May 20 '23 08:05

marc_s


Thanks for the response I figured out what was wrong.

Apparently all my SqlDataSource connection strings, inside of the Admin.aspx, had changed from using the connection string that pointed at the correct database (WIJL), to the connection string WIJLConnectionString1 which pointed at the ASPNETDB database. All I had to do was just change the connections strings back

like image 39
Philip906 Avatar answered May 20 '23 09:05

Philip906