CREATE DATABASE permission denied in database 'master'. when publishing to web server - asp.net

I know that this question was asked so many times but none of the theme worked for me.
I have published a mvc website to a plesk control panel web server but I continuously get this error:
CREATE DATABASE permission denied in database 'master'.
Can anyone tell me what's going on ? I spent three days and tried everything.
here is my connection string:
<connectionStrings>
<add name="application" connectionString="Data Source=.;Initial Catalog=bug.mdf;Integrated Security=false; User ID=admin;Password=###############" providerName="System.Data.SqlClient" />
</connectionStrings>
Error:
[SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2434922
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736592
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +3731
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +940
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +272
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +280
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +356
System.Data.Entity.SqlServer.<>c__DisplayClass1a.<CreateDatabaseFromScript>b__19(DbConnection conn) +119
System.Data.Entity.SqlServer.<>c__DisplayClass33.<UsingConnection>b__32() +443
System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +10
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +189
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +78
System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +175
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +556
System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +86
System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +164
System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +76
System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134
System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +119
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +142
System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78
System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext) +89
System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +151
System.Data.Entity.Internal.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() +76
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +357
System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +110
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +198
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +38
System.Linq.Queryable.OrderByDescending(IQueryable`1 source, Expression`1 keySelector) +83

The error is entirely straight-forward. Your application is attempting to create a database and the database user it's connecting with does not have that permission. As to why that's occurring, it's difficult to say with the infomation provided. Assuming you're not actually attempting to explicitly create a database in your code, it's most likely due to the database initialization strategy set on your context. The default is to attempt to create the database if it does not exist. As a result, you should ensure that the instance you're connecting to does indeed have the database your application is attempting to work with.
You could also simply give the DB user permission to create the database, but that would be an extremely bad idea, security wise. Your web application's DB user should always have the most limited set of permissions possible, basically just SELECT, INSERT, UPDATE, and DELETE, and maybe not even all of those. You might need EXECUTE as well in some scenarios, but you can grant that on an object-by-object basis, rather than globally.

I think you are missing the database name i.e initial catalog in your connection string
<connectionStrings>
<add name="application" connectionString="Data Source=.;Initial Catalog=NameOFDB; Integrated Security=false; User ID=admin;Password=#slfsl$4554sll%" providerName="System.Data.SqlClient" />
</connectionStrings>

Related

ASP.NET SQL Error Loading Page

We're getting the following error message when trying to login to our ASP.NET application:
Server Error in '/' Application.
The wait operation timed out
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: The wait operation timed out
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): The wait operation timed out]
[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +1753346
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +5295154
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1682
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +59
System.Data.SqlClient.SqlDataReader.get_MetaData() +90
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +365
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +1325
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +175
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +134
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10
System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +437
[EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details.]
System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) +507
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context, ObjectParameterCollection parameterValues) +675
System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) +102
System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +30
System.Linq.Enumerable.Single(IEnumerable1 source) +100
System.Data.Objects.ELinq.ObjectQueryProvider.b__3(IEnumerable1 sequence) +5
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable1 query, Expression queryRoot) +25
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +70
System.Linq.Queryable.Count(IQueryable`1 source) +233
BioWaveWeb.Default.Page_Load(Object sender, EventArgs e) +790
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
Can someone assist or give any comments on how to resolve this?
It appears your ASP.NET application is making a call to a SQL Server database via a COM (Component Object Model) component, but something in or downstream of that component is failing and causing the request to the database to time out. You're almost certainly going to have to get in touch with some development staff that can debug this issue in particular to determine what component(s) is/are involved, what servers are being contacted, and what intermediate error(s) may be occurring that are causing the failure/timeout. Very difficult to provide much more detail than that at this point based on this stack trace.
EDIT: A true "timeout" could be indicative of something inside a stored procedure that is becoming stuck in an infinite loop (as one possibility). There are myriad other possibilities, so take that as merely one possibility among many.

EXECUTE permission denied - 'aspnet_Roles_RoleExists'

I am installing an application (BlogEngine) in a virtual directory under the main website, using SQL Server (MSSQLBlogProvider). BlogEngine has it's own database.
All worked, meaning I got the default page served from the SQL Database.
Then I used the ASP.net website administration tool\Security to create users (like shown in this video http://www.nyveldt.com/misc/BE13SQLMembership.html around the 7 minute mark. Very well explained and it's easy and fast to see what he is doing if you click around the timeline of the video)
After following those steps I get the error:
The EXECUTE permission was denied on the object 'aspnet_Roles_RoleExists', database 'Blog', schema 'dbo'. I to play around with the Access Rules but with no success.
Note that I am using "integrated security".
I'm not exactly shure whre to look and where to make modifications. Any help is hightly appreciated.
Stack Trace:
[SqlException (0x80131904): The EXECUTE permission was denied on the object 'aspnet_Roles_RoleExists', database 'Blog', schema 'dbo'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +388
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +688
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6665097
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +6667096
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +577
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +735
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +290
System.Web.Security.SqlRoleProvider.RoleExists(String roleName) +967
System.Web.Security.Roles.RoleExists(String roleName) +336
BlogEngine.Core.Right.InitRightForBlogInstance() in j:\Projects\BlogEngine_2_7_0_0\blogengine_4f5eed923a57\BlogEngine\BlogEngine.Core\Security\Right.cs:612
BlogEngine.Core.Right.get_RightsByRole() in j:\Projects\BlogEngine_2_7_0_0\blogengine_4f5eed923a57\BlogEngine\BlogEngine.Core\Security\Right.cs:600
BlogEngine.Core.Right.EnsureBlogInstanceDataLoaded() in j:\Projects\BlogEngine_2_7_0_0\blogengine_4f5eed923a57\BlogEngine\BlogEngine.Core\Security\Right.cs:566
BlogEngine.Core.Right..cctor() in j:\Projects\BlogEngine_2_7_0_0\blogengine_4f5eed923a57\BlogEngine\BlogEngine.Core\Security\Right.cs:113
[TypeInitializationException: The type initializer for 'BlogEngine.Core.Right' threw an exception.]
BlogEngine.Core.Right..ctor() in j:\Projects\BlogEngine_2_7_0_0\blogengine_4f5eed923a57\BlogEngine\BlogEngine.Core\Security\Right.cs:539
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256
System.Activator.CreateInstance(Type type, Boolean nonPublic) +127
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +14376269
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +200
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +83
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +335
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601
Open Internet Information Services Manager
Check what Application Pool your IIS Website is using
Go to Application Pools
See what Identity your App Pool is running under
Open SQL Server Management Studio
Connect to your SQL Server instance
Open a New Query for your database
Run this SCRIPT:
GRANT SELECT, EXECUTE, UPDATE, INSERT ON SCHEMA :: dbo TO
[NT AUTHORITY\NETWORK SERVICE]
*Replace [NT AUTHORITY\NETWORK SERVICE] with whatever Identity your App Pool is running as.
Go back to IIS Manager
Recycle your App Pool
Browse to your website

Login failed for user 'ndt', help me decipher the stack trace please

I am working with someone else's code.
Trying to get it sorted out.
We re-imaged our server and uploaded fresh clean files.
(identical to the previous ones, only these are not infected)
I also restored the backup I created of the database.
Everything worked before, but now we are having issues.
I have no experience with this type of authentication.
It appears to go through an mdf file before querying the data.
Can't seem to get around the Login failed for user error.
[SqlException (0x80131904): Login failed for user 'ndt'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +187
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2297
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +34
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +606
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +220
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +502
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +512
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +104
System.Data.SqlClient.SqlConnection.Open() +177
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +118
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1748
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +13
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +68
System.Web.UI.WebControls.GridView.DataBind() +4
NDTCourses.TimeKeeping.WebForm14.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\cflick\Desktop\NDTCourses\NDTCourses\TimeKeeping\declare_time.aspx.cs:264
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +98
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4315
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=TECH-ILL\\SQLEXPRESS;Initial Catalog=timeKeep;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="db" connectionString="Data Source=TECH-ILL\\SQLEXPRESS;Initial Catalog=timeKeep;Integrated Security=True" />
<add name="timeKeepConnectionString" connectionString="Data Source=TECH-ILL\SQLEXPRESS;Initial Catalog=timeKeep;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Either the ndt server login no longer exists or the server login is no longer associated with the database user (commonly called an orphaned user).
In the first case, you need to create the database login and then handle the orphaned user.
Orphaned users happen when restoring databases to new or rebuilt servers or when recreating database logins. You can find instructions on fixing this problem at http://msdn.microsoft.com/en-us/library/ms175475.aspx.

asp.net webforms app trying to connect to database that isn't being referenced anywhere in code?

I had a few old database on my server, so took the older, unused ones offline.
This has caused a very strange problem, in that my site is complaining about not being able to connect to one of these databases.
I have searched the entire code-base for the database name, as well as all the config files on the server, and none of them reference this database name, yet if I take if offline, I get an error?
I can't see from the error what is actually making the request to connect, apart from it looks like its related to the SQL Session Server.
[SqlException (0x80131904): Database 'MyOldDatabaseName' cannot be
opened because it is offline.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) +1953274
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +4849707
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) +2392
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +96
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) +141
System.Data.SqlClient.SqlCommand.ExecuteReader() +89
System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext
context, String id, Boolean getExclusive, Boolean& locked, TimeSpan&
lockAge, Object& lockId, SessionStateActions& actionFlags) +516
[HttpException (0x80004005): Unable to connect to SQL Server session
database.]
System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection
conn, Exception e) +229
System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext
context, String id, Boolean getExclusive, Boolean& locked, TimeSpan&
lockAge, Object& lockId, SessionStateActions& actionFlags) +649
System.Web.SessionState.SqlSessionStateStore.GetItemExclusive(HttpContext
context, String id, Boolean& locked, TimeSpan& lockAge, Object&
lockId, SessionStateActions& actionFlags) +48
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +117
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData) +487
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+66 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
You know it's a web application. You can go to IIS, stop all web sites, take the database offline and see if the error appears. If you can't reproduce it, some web site is connecting to the database and you aren't checking its source code. You can then start the sites one by one until it breaks.
Hope it helps!
did you Clean your solution? Try cleaning it and then rebuild it. Also , you need to check what happens when you bring that database back online.Check in your IIS for any Connection String that may be refering to this site.
HttpException (0x80004005): Unable to connect to SQL Server session database indicates that you are/were using SQL Server to store session state. Look in your web.config for the sessionState element under configuration -> system.web. If the mode attribute is set to SQLServer, then there will be a sqlConnectionString attribute with the connection string. You can change the mode from SQLServer to InProc to move to an in memory solution and away from SQL Server. For load balanced environments you'll have to stick with SQL Server or the in-memory State Server.
Set your database online with the MSSQL query below:
ALTER DATABASE <database-name> SET ONLINE
In addition, the MSSQL query below set your database offline:
ALTER DATABASE <database-name> SET OFFLINE

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
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??
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

Resources