Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>SQL CE 3.5 does not work with ASP.NET, you must use 4.0 CTP.</p> <p>Download from <a href="http://www.microsoft.com/download/en/default.aspx" rel="noreferrer">here</a>.</p> <p>Install the runtime.</p> <p>Copy the following directory contents (including the x86 and amd64 folders) to the bin folder of your ASP.NET app: C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private</p> <p><strong>UPDATE: Use System.Data.SqlServerCe.dll from the Desktop folder to avoid Medium Trust issues</strong></p> <pre><code>myapp\bin\ System.Data.SqlServerCe.dll myapp\bin\x86 sqlceca40.dll sqlcecompact40.dll sqlceer40EN.dll sqlceme40.dll sqlceqp40.dll sqlcese40.dll myapp\bin\amd64 sqlceca40.dll sqlcecompact40.dll sqlceer40EN.dll sqlceme40.dll sqlceqp40.dll sqlcese40.dll </code></pre> <p>Add a reference to the System.Data.SqlServerCe.dll file you just put in your /bin folder.</p> <p>Place the SQL Compact sdf file in your App_Data folder.</p> <p>Add connection string:</p> <pre><code>&lt;connectionStrings&gt; &lt;add name ="NorthWind" connectionString="data source=|DataDirectory|\Nw40.sdf" /&gt; &lt;/connectionStrings&gt; </code></pre> <p>Connect! :-)</p> <pre><code>using System.Data.SqlServerCe; protected void Page_Load(object sender, EventArgs e) { using (SqlCeConnection conn = new SqlCeConnection()) { conn.ConnectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString; conn.Open(); using (SqlCeCommand cmd = new SqlCeCommand("SELECT TOP (1) [Category Name] FROM Categories", conn)) { string valueFromDb = (string)cmd.ExecuteScalar(); Response.Write(string.Format("{0} Time {1}", valueFromDb, DateTime.Now.ToLongTimeString())); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload