SQL Compact database + asp.net : “System.NotSupportedException: SQL Server Everywhere Edition is not intended for ASP.NET development.”

When happen to connect SQL Compact database with asp.net application you might have got the error below:

System.NotSupportedException: SQL Server Everywhere Edition is not intended for ASP.NET development

Reason:

SQL Server Compact 3.5 is not currently optimized to serve as a database for Web sites. By default, connections from ASP.NET-connected applications are blocked.

SQL Server Compact 3.5 is optimized for use as an embedded database within applications. Using SQL Server Compact 3.5 as a database for Web sites requires support for multiple users and concurrent data changes. This can cause performance problems. As a database for Web sites, use SQL Server 2005 and later versions, or SQL Server 2005 Express Edition and later versions. These platforms are more appropriate for Web sites.

Use SQL Server Compact 3.5 with ASP.NET in application scenarios where ASP.NET is used to create SQL Server Compact 3.5 databases for synchronization. Use the following code to change the default behavior of SQL Server Compact 3.5 to work within ASP.NET.

Solution:

Just add the below said attribute in your app domain in application start event handler of your asp.net / Silverlight web site:

AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true)

Code Block:
Place the below code bock in application start event handler of global.asax of your application. If you don't find global.asax  in your application  by default then via ‘add new item’ menu add Global.asax to your application.

void Application_Start(object sender, EventArgs e)
  {

     // Code that runs on application startup

      AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true)

  }

Also refer SQL Server Compact 3.5 Deployment Considerations : http://msdn.microsoft.com/en-us/library/ms174612.aspx

 

– Ananth Ramasamy Meenachi  www.msarm.com

Advertisements

About msarm

Aspiring Enterprise Architect.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s