locked
Access to the database file is not allowed. RRS feed

  • Question

  • User-735851359 posted

    Hello,

    my site is giving the following error. how can i solve that?

    -------------------------

    Server Error in '/' Application.


    Access to the database file is not allowed. [ 1914,File name = d:\HostingSpaces\wyasqiol\cubukindirim.com\wwwroot\App_Data\db.sdf,SeCreateFile ]

    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.SqlServerCe.SqlCeException: Access to the database file is not allowed. [ 1914,File name = d:\HostingSpaces\wyasqiol\cubukindirim.com\wwwroot\App_Data\db.sdf,SeCreateFile ]

    Source Error: 

    Line 1:  @{
    Line 2:      WebSecurity.InitializeDatabaseConnection("db", "UserProfile", "UserID", "Email", true);
    Line 3:      WebMail.SmtpServer = "mail.cubukindirim.com";
    Line 4:      WebMail.SmtpPort =  25;


    Source File: d:\HostingSpaces\wyasqiol\cubukindirim.com\wwwroot\_AppStart.cshtml    Line: 

    Stack Trace: 

    [SqlCeException (0x80004005): Access to the database file is not allowed. [ 1914,File name = d:\HostingSpaces\wyasqiol\cubukindirim.com\wwwroot\App_Data\db.sdf,SeCreateFile ]]
       System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) +2182
       System.Data.SqlServerCe.SqlCeConnection.Open() +47
       WebMatrix.Data.Database.EnsureConnectionOpen() +46
       WebMatrix.Data.<QueryInternal>d__0.MoveNext() +67
       System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +189
       WebMatrix.Data.Database.QuerySingle(String commandText, Object[] args) +98
       WebMatrix.WebData.DatabaseWrapper.QuerySingle(String commandText, Object[] parameters) +14
       WebMatrix.WebData.SimpleMembershipProvider.CheckTableExists(IDatabase db, String tableName) +54
       WebMatrix.WebData.SimpleMembershipProvider.CreateTablesIfNeeded() +50
       WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +70
       WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
       WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +52
       ASP._Page__appstart_cshtml.Execute() in d:\HostingSpaces\wyasqiol\cubukindirim.com\wwwroot\_AppStart.cshtml:2
       System.Web.WebPages.ApplicationStartPage.<ExecuteInternal>b__0() +49
       System.Web.WebPages.ApplicationStartPage.<GetSafeExecuteStartPageThunk>b__3(Action action) +7
       System.Web.WebPages.ApplicationStartPage.ExecuteInternal() +64
       System.Web.WebPages.ApplicationStartPage.ExecuteStartPageInternal(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +163
       System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +31
    
    [HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
       System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +80
       System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application) +136
       System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application, Action`1 executeStartPage, EventHandler applicationStart) +94
       System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application) +54
       System.Web.WebPages.WebPageHttpModule.Init(HttpApplication application) +200
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
    
    [HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931916
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
    Tuesday, August 18, 2015 4:15 PM

Answers

All replies

  • User2024324573 posted

    It seems to be your LocalDB database file is missing - what you can do go to App_Data folder, see if there is any file or not, if not create a new one and name it. 

    Change you connection string accordingly and try it again.

    Also you can make sure you are able to connect LocalDB server (installed with Visual studio or separately) via Server Explorer or SQL Server management studio.

    Hope this will help.

    Tuesday, August 18, 2015 4:24 PM
  • User-735851359 posted

    the database file is in the App_Data folder

    Wednesday, August 19, 2015 5:40 PM
  • User325035487 posted

    By default IIS uses Network Service or ApplicationPoolIdentity, not the local Windows account. So it is needed to grant those accounts access to SQL Server. Please refer to http://www.iis.net/learn/manage/configuring-security/application-pool-identities for more information.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 24, 2015 9:46 AM