SQL 2008 Compact Edition 4.0 issue

Discussion in 'General troubleshooting' started by jamesbond, May 27, 2011.

  1. Hi guys,

    I managed to get my site published from WebMatrix using the StarterSite template - with zero change on the site. The site runs properly on my local PC.

    However, I cannot get the DB to work in Winhost. I have disabled the LocalSqlServer connection string in my web.config
    <remove name="LocalSqlServer" />

    Locally, I don't see the need of connection string, considering the code to call the db:
    var db = Database.Open("StarterSite");

    simply look at the /App_Data/StarterSite.sdf.

    I know I can easily move to SQL Express, but I still need to have flexibility of file based db here.

    Can somebody shed the light here?


  2. I narrow it down to the following:

    <add name="StarterSite" connectionString="Data Source=e:\inetpub\wwwroot\App_Data\Other.sdf" providerName="System.Data.SqlServerCe.4.0" />

    Apparently, if the connection sting is not successful, it will try to refert to default.

    I think the path I specified is incorrect, anyone can suggest a better physical path?

    Could this be a limitation in the hosting preventing us to access physical path? If it can, I assume anyone can access my file in the shared hosting environment.
    Could it t
  3. Finally got it pass the wrong path - but a new error
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=[your physical path eg. e:\somefolder\somefolder]\App_Data\Other.sdf" providerName="System.Data.SqlServerCe.4.0" />

    Now the error is different:

    ProviderException: The Role Manager feature has not been enabled.]
    System.Web.Security.Roles.EnsureEnabled() +2229477
    System.Web.Security.Roles.get_Provider() +8
    WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +56
    WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +52
    ASP._Page__AppStart_cshtml.Execute() +31
    System.Web.WebPages.ApplicationStartPage.<ExecuteInternal>b__3() +49
    Microsoft.Web.Infrastructure.HttpContextHelper.ExecuteInNullContext(Action action) +75
    System.Action`1.Invoke(T obj) +0
    System.Web.WebPages.ApplicationStartPage.ExecuteInternal() +64
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPageInternal(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +186
    System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +42
  4. After spending all day and dealing with incompetent support team from Winhost, I have finally solved the problem that should only take 10 seconds to fix.

    I have recreate this few times and it works.

    step 1. Create a site using WebMatrix and use StarterSite template
    Step 2. Configure the publishing using WebDeploy
    server: https://[your server name e.g. w06].Winhost.com:8172/MsDeploy.axd
    use your Control Panel login
    For site: use your real site domain mysite.com
    for URL: please make sure you add http:// e.g. http://mysite.com

    Step 3. publish the site to get a web.config file automatically generated.

    Step 4. edit the web.config
    Before you edit, make sure you go to the control panel and find out about the physical folder of your webroot - they called it "Path to the root"

    Add the following into your web.config
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=[your webroot path here]\App_Data\StarterSites.sdf" providerName="System.Data.SqlServerCe.4.0" />
    <add key="enableSimpleMembership" value="true" />

    Step 5. Publish the site and it should work now.
    Last edited by a moderator: Oct 14, 2015
  5. I was given the wrong path about .cshtml or setting default document, you don't need to download iis admin to configure this. It should work out of the box.
  6. James,

    I don't know if Her Majesty and Miss Moneypenny appreciate this but I do.

    Here we are sitting at out localhost running WebMatrix StarterSite, interacting with security, adding roles and memberships and employing those attributes to control access to various parts of our localhost website.

    Yes, we know how to deploy; it goes without a hitch.

    Yet, what is this? An error, can't find LocalSqlServer? Why? We are not using it. After many hours of frustration, you find the answer, add a section in your web.config to remove the named string "LocalSqlServer" (I did it different than you) and now let's see what we have.

    Nope, another error. Don't have roles management enabled?

    Frankly, James I don't think anyone else is actually trying this. I don't think these are our mistakes and they are repeatable, just follow the existing instructions and you will encounter the same frustrating events.

    I am going to see if the "enable simplesecurity" works for me. In the end, if this works out, there needs to be some changes at least as supplements to the documentation.

    Thanks again.
  7. BTW, jamesbond this did not work for me. I think we are not providing for our AspNetMembership provider.

    I started another thread to add on to your work called "StarterSite Deployment with Gun and Camera".

    I am also going to bring this to the attention of our microsoft friends because I do not think WebMatrix is living up to its contract.
  8. Hi, James

    Did you ever get this solved?

    I can help read my post "SQL Deployment". If you need more information (like changes to the web.config that you MUST add) contact me.
  9. ccosborn,

    I'm in great need of some assistance with connection strings, as well. See the thread under Databases/entity data connection string

    Any help would be greatly appreciated.

  10. Can't help you. I have lots of connection strings and also lots of problems.

    Thought I was making progress by using ASP.net documentation and some third party books. Every procedure goes without a hitch but the website does not like it.
  11. Ray


    Using webmatrix to do your ASP.Net Membership/Roles provider is really not as straight forward as you would think. First and foremost you will need to manually add the Binaries/Assemblies as you upload the site to the web server. this gets misleading because when you test it on your local computer everything seems to work perfectly but when you upload it to the web server you get all kinds of errors. The first error you will probably see is the error that reads LocalSqlServer was not found. This is not a web matrix problem yet. You can fix this problem by setting this element in your web.config file. KB

    But before all that you will need to make sure you you upload the required Binaries/Assemblies with your web matrix app. To do this in your web matrix go to the Web Pages Administration and log into it. On the packages make sure you choose "Source" Default All. Type on the search box security and look for SimpleMembership.Mvc3.Sample.1.0 and install it. This will also add the assembly to your Bin folder. Then deploy it making sure all these dll files are uploaded to the web server inside the Bin folder. Lastly make sure you publish your local database to our SQL server and you update the connection string. If you are planning to use SQL CE v4, you will need to simply update the connection string to point to the path were your SQL CE v4 exists.
    Last edited by a moderator: Oct 14, 2015
  12. Thank you for the input, Ray. I am unclear on how to modify the connection string. If I use SQL CE v4, then the entire string would look like this?
    <add name="LocalSqlServer" connectionString="Data Source=E:\web\[root_folder]\[site_folder]\bin\System.Data.SqlServerCe.Entity;
    Integrated Security=false;Initial Catalog=DB_26362_startersite1;
    User ID=DB_26362_startersite1_user;Password=xxxx" providerName="System.Data.SqlClient" />
    The rest of the string was generated for me when I created a db for the site.

    Please bear with me as I am just learning asp.Net and the whole SQL thing.

  13. Never mind, I figured it out, would not have without the info in your post. I also changed my account from earlibir to 0000148.
  14. Thank you

    @jamesbond Almost a year later and still this post saved me lots of hair pulling, thank you for solving this.

Share This Page