How to install the
Microsoft.SQLSERVER.CE.OLEDB.4.0 Provider and use classic ASP to connect to an SqlCe (SQL Server Compact) database sdf file. As a Microsoft Access database replacement. For IIS 7+ (7.0, 7.5, 8.0). SQL Server Compact (SqlCe), the embedded database engine, is the default database for Visual Studio 2010 SP1 and WebMatrix 3. This means, you can better make use of SqlCe than Access nowadays.
Replace MS Access database with SqlCe
But there is a new kid in town: SQL Compact Server 4.0, or SqlCe for short.
SqlCe database of choice with WebMatrix 3
SQL Server Compact, the embedded database engine, is the default database for Visual Studio 2010 SP1 and WebMatrix 3. This means, you can better make use of SqlCe than Access nowadays. Practically every hostingprovider should support the use of SqlCe databases, We at Vevida do.
Microsoft SQL Server Compact 4.0 is a free, embedded database that software developers can use for building ASP.NET websites and Windows desktop applications. SQL Server Compact 4.0 has a small footprint and supports private deployment of its binaries within the application folder, easy application development in Visual Studio and WebMatrix, and seamless migration of schema and data to SQL Server.
Download and install SQL Server Compact 4.0
Example ASP-script how to connect with an SqlCe database sdf file
This piece of ASP-code connects to an SqlCe database, performs a query and list all fields. You need to set the correct path to your database file.
set conn = Server.CreateObject("ADODB.Connection")
strCnxn = "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;" & _
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM table", conn
do until rs.EOF
for each x in rs.Fields
Response.Write(" = ")
Response.Write(x.value & "<br />")
Set conn = Nothing
The SqlCe database engine has great performance and is a really great replacement for your old Microsoft Access databases. If you still use MS Access, convert and migrate Access to SqlCe. You won’t regret it.