Symptoms

If we move the SQL Server CE database from one platform to another platform, the application may fail with the following error message

Exception type: System.Data.SqlServerCe.SqlCeException

Message: SQL Server Compact has exceeded the buffer size. The default size can be increased on initialization by modifying the ssce: max buffer size property. [ The default size = 4194304 ]

InnerException: <none>

StackTrace (generated):

    SP       IP       Function

    0488E9C4 0073C7A1 System.Data.SqlServerCe.SqlCeConnection.ProcessResults(Int32)

    0488E9C8 0073C396 System.Data.SqlServerCe.SqlCeConnection.Open(Boolean)

    0488EA6C 0073BA8D System.Data.SqlServerCe.SqlCeConnection.Open()

    0488EA9C 00739251 Microsoft.Practices.EnterpriseLibrary.Data.Database.GetNewOpenConnection()

 

Cause
This is by Design. When moving the SQL Server CE database from one platform to another platform, the first DB connection will re-build indexes and also the size of the database increases which requires additional buffer

Refer to our SQL Server CE Team Blog where they have given the reason for why the Size of the SQL Server CE database gets increased when we move from one platform to another.

http://blogs.msdn.com/sqlservercompact/archive/2009/04/01/after-moving-the-database-from-one-platform-to-other-the-first-sqlceconnection-open-takes-more-time.aspx

Resolution

 

To resolve this issue set the Buffer Size to 8MB in the connection string. The Buffer Size is in KB. The default buffer size is 640kb.
Eg:         
Source=C:\Test\TestDB.sdf; SSCE:Max Buffer Size=8192

Reference
http://msdn.microsoft.com/da-dk/library/system.data.sqlserverce.sqlceconnection.connectionstring(en-us).aspx

Author : Praveen M(MSFT) , SQL Developer Technical Lead , Microsoft

Reviewed by : Sunil (MSFT), SQL Escalation Services , Microsoft