locked
SqlCeException (0x80004005) Trying to load a page with GridView and a SqlDataSource connecting to SQL CE 4 sdf file RRS feed

  • Question

  • Hello,

    On my local machine everything works fine.

    I have uploaded my website to an ISP and while trying to open a page with GridView and a SqlDataSource connecting to SQL CE 4 sdf file following exception gets generated.

    Server Error in '/' Application.


    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: [ 1884,d:\DZHosts\LocalUser\gasasso\www.gasasso.somee.com\App_Data\gasasso.sdf,SeCreateFile ]

    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:

    [SqlCeException (0x80004005): [ 1884,d:\DZHosts\LocalUser\gasasso\www.gasasso.somee.com\App_Data\gasasso.sdf,SeCreateFile ]]
      System.Data.SqlServerCe.SqlCeConnection.ProcessResults(Int32 hr) +24
      System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) +1612
      System.Data.SqlServerCe.SqlCeConnection.Open() +52
      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.Control.PreRenderRecursiveInternal() +175
      System.Web.UI.Control.PreRenderRecursiveInternal() +175
      System.Web.UI.Control.PreRenderRecursiveInternal() +175
      System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
    


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

    [ 1884,d:\DZHosts\LocalUser\gasasso\www.gasasso.somee.com\App_Data\gasasso.sdf,SeCreateFile ]

     

    I couldn't make out why this happens. Any help is appreciated.

     

    Wednesday, February 16, 2011 10:09 AM

All replies

  • Insufficent rights in the App_Data folder?
    Visit my SQL Compact blog - http://erikej.blogspot.com - Please mark as answer, if this was it.
    Saturday, February 19, 2011 4:26 PM
  • Hi... @Falcon31, i'm facing exactly same problem @Erikej ,could you please provide a complete link to this solution? i visited your blog and couldnot find the solution
    Sunday, February 20, 2011 3:19 AM
  • Hi,

    Did you figure this out? I'm having the same problem and the answer eludes me :-(

    Let me know,

    Glyn.

    The answer:

    On your development machine all works ok out of the box. No changes here.

    On your test server (if you have one) give NETWORK SERVICE full control of the App_Data folder and the test application will work from there too.

    On your external shared hosting account use the file manager to give read+write access to the App_Data folder and now your application should work from the interweb as well.

    • Proposed as answer by Deep-Thought Thursday, March 24, 2011 3:43 PM
    Thursday, February 24, 2011 6:20 PM
  • Hi, .. I'm having the same problem :-(
    Thursday, March 24, 2011 12:56 PM
  • On your development machine all works ok out of the box. No changes here.

    On your test server (if you have one) give NETWORK SERVICE full control of the App_Data folder and the test application will work from there too.

    On your external shared hosting account use the file manager to give read+write access to the App_Data folder and now your application should work from the interweb as well.

    Thursday, March 24, 2011 3:43 PM
  • Thanks for your response. However, for testing purpose, I have uploaded my site on somee.com.

    Here, there is no explicit option for setting the read+write access to App_Data folder, however, on searching the help, I found that by default every folder is having read+write access, it further stats that I need to remove <Identity impersonate tag from my web.config file. In my case there is no such tag in web.config.

    The exact text of the help on somee.com is

    "

    Grant write, modify, delete access rights on website's folder
    Your website executes under unique user account that by default has full control over the website's folder.
    So your application can create, open, read, write and delete files and folders inside of your root folder.
    There is no need and no way to change this permissions.
    If, when running ASP.Net application, you still unable to create file or update it, you have to check your Web.Config file for "<Identity impersonate..." tag and remove it.
    The only exception is when the application tries to modify a file or folder in "Application_Start" event of Global.asax file. This is by design that user authenticated only after the Application_Start even. Before the user is authenticated your website runs under an identity of Application Pool which is "Network services". That account doesn't have access to the folder of your website.
    To make it work you eather have to move the code that tries to modify files or folders out of the "Application_Start" event of the Global.asax file or inside the event you'll need to impersonate your user by code."

    Any further guidelines please.

     


    Saturday, April 2, 2011 11:37 AM
  • Hi falcon31,

    You seem to have answered your own question :-)

    NETWORK SERVICE needs access to the App_Data folder and your host is set so that (quoting from your message above) "Before the user is authenticated your website runs under an identity of Application Pool which is "Network services". That account doesn't have access to the folder of your website."

    My hosting service provides a control panel for my account which includes a file manager type interface where I can navigate through the site folders adding, deleting and changing permissions as I wish. If your host doesn't provide such an interface then perhaps you should email them and ask if they can set the permissions on your App_Data folder for you so that the  NETWORK SERVICE acoount has read+write access to the folder and anything it contains.

    Hope that helps,

    Glyn.

     

    Monday, April 4, 2011 12:04 PM