title: How to deploy SQL Server Compact Edition 4.0?
body: <p>How do i deploy <a href="http://www.microsoft.com/en-us/download/details.aspx?id=17876">Microsoft SQL Server Compact 4.0</a>?</p>
  
  <hr>
  
  <p>SQL Server Compact Edition (currently at version 4.0) is:</p>
  
  <blockquote>
    <p>a free, embedded database that software developers can use for building Windows desktop applications. It has a small footprint and supports private deployment of its binaries within the application folder.</p>
  </blockquote>
  
  <p>But how do you actually deploy it? </p>
  
  <ul>
  <li>Microsoft says it <strong>can</strong> be <a href="http://channel9.msdn.com/coding4fun/blog/SQL-Server-Compact-Edition-40-Toolkit-v2-Dont-leave-your-Visual-Studio-without-it">deployed within the application folder (<em>good</em>) and supports xcopy deployment</a>.</li>
  <li>Microsoft also says it <strong>cannot</strong> be <a href="http://support.microsoft.com/kb/920700">deployed within the application folder (<em>bad</em>), and does not support xcopy deployment</a>.</li>
  <li>some people have <a href="http://robindotnet.wordpress.com/2010/02/28/how-to-deploy-the-sqlserver-compact-edition-software-locally/">examples of it using simple xcopy deployment</a>, but they don't go into the details required to complete the deployment</li>
  </ul>
  
  <p>The problem is that you cannot use the ADO OLEdb provider unless it is registered. Registering an OLEdb provider has to be done as an administrator. That means that SQL Server Compact edition will fail with users who are not an administrator.</p>
  
  <p>SQL Server Compact 4.0 comes with a <code>redist_enu.txt</code> file:</p>
  
  <blockquote>
    <p>The listed .exe files each install its enclosed components to a specific location on the destination computer.  This helps to ensure serviceability and technical support.  The .dll files enclosed in these .exe files are also available separately in this redist.txt.  However, distributions of these separate .dlls may result in issues of serviceability.  For more details, please see <a href="http://go.microsoft.com/fwlink/?LinkId=94589">http://go.microsoft.com/fwlink/?LinkId=94589</a></p>
    
    <p>Private deployment detection via BreadCrumb:  Private deployment of just the native stack and explicit loading of SQL Server Compact Assembly via Assembly.LoadFrom(), .local file, or the use of DLL/COM redirection strategies are not supported and may result in serviceability issues.  For more information see <a href="http://support.microsoft.com/kb/835322">http://support.microsoft.com/kb/835322</a> and <a href="http://msdn2.microsoft.com/en-us/library/aa375142.aspx">http://msdn2.microsoft.com/en-us/library/aa375142.aspx</a></p>
    
    <h2>Microsoft SQL Server Compact 4.0</h2>
    
    <p>SSCERuntime_x86-ENU.exe<br>
    SSCERuntime_x86-DEU.exe<br>
    SSCERuntime_x86-FRA.exe<br>
    SSCERuntime_x86-JPN.exe<br>
    SSCERuntime_x86-RUS.exe<br>
    SSCERuntime_x86-ESN.exe<br>
    SSCERuntime_x86-ITA.exe<br>
    SSCERuntime_x86-KOR.exe<br>
    SSCERuntime_x86-CHT.exe<br>
    SSCERuntime_x86-CHS.exe<br>
    SSCERuntime_x64-ENU.exe<br>
    SSCERuntime_x64-DEU.exe<br>
    SSCERuntime_x64-FRA.exe<br>
    SSCERuntime_x64-JPN.exe<br>
    SSCERuntime_x64-RUS.exe<br>
    SSCERuntime_x64-ESN.exe<br>
    SSCERuntime_x64-ITA.exe<br>
    SSCERuntime_x64-KOR.exe<br>
    SSCERuntime_x64-CHT.exe<br>
    SSCERuntime_x64-CHS.exe<br>
    sqlcese40.dll<br>
    sqlceqp40.dll<br>
    sqlceoledb40.dll<br>
    sqlceca40.dll<br>
    sqlceme40.dll<br>
    sqlcecompact40.dll<br>
    sqlceer40en.dll<br>
    sqlceer40cn.dll/sqlceer40zh-CHS.dll<br>
    sqlceer40de.dll<br>
    sqlceer40es.dll<br>
    sqlceer40fr.dll<br>
    sqlceer40it.dll<br>
    sqlceer40ja.dll<br>
    sqlceer40ko.dll<br>
    sqlceer40tw.dll/sqlceer40zh-CHT.dll<br>
    sqlceer40ru.dll<br>
    System.Data.SqlServerCe.dll<br>
    System.Data.SqlServerCe.Entity.dll  </p>
  </blockquote>
  
  <p>but it doesn't give any information about how to redistribute SQL Server Compact 4.0.</p>
  
  <p>Randomly spellunking around the undocumented <code>Program Files</code> folder i found 7 dlls:</p>
  
  <pre><code>C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\
        sqlceoledb40.dll
        sqlceqp40.dll
        sqlcese40.dll
        sqlceca40.dll
        sqlcecompact40.dll
        sqlceer40EN.dll
        sqlceme40.dll
  </code></pre>
  
  <p><strong>Note:</strong> There are also some child folders with more dlls</p>
  
  <p>i tried copying these 7 dll's to a folder, and tried to open an <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms681519%28v=vs.85%29.aspx">ADO Connection</a> using <a href="http://www.quickersite.com/r/default.asp?iID=HFJJLH&amp;iPostID=MFLDKE">the connection string</a>:</p>
  
  <pre><code>Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source="store.sdf"
  </code></pre>
  
  <p>but it fails with <code>0x80004005 Unspecified error</code></p>
  
  <p><a href="http://blogs.msdn.com/b/oldnewthing/archive/2011/01/20/10117963.aspx">i tried frobbing the widget, but it grobbed the frobber.</a></p>