SIGN UP MEMBER LOGIN:    
ARTICLE

Connection Strings for SQL Server Compact Edition

Posted by Nipun Tomar Articles | SQL December 22, 2010
SQL Server Compact Edition (SQL CE) is a compact relational database produced by Microsoft for applications that run on mobile devices and desktops.
Reader Level:

SQL Server Compact Edition (SQL CE) is a compact relational database produced by Microsoft for applications that run on mobile devices and desktops. SQL CE targets occasionally-connected applications and applications with an embedded database It includes ADO.NET providers for data access using ADO.NET APIs, and built-in synchronization capabilities, as well as support for LINQ and Entity Framework. SQL CE supports transactions, referential integrity constraints, locking as well as multiple connections to the database store.

Providers for SQL Server Compact Edition9

  • .NET Compact Framework Data Provider for SQL Server Mobile (SqlCeConnection)
  • .NET Framework Data Provider for OLE DB (OleDbConnection)
  • Microsoft.SQLSERVER.CE.OLEDB.3.5
  • Microsoft.SQLSERVER.MOBILE.OLEDB.3.0

.NET Compact Framework Data Provider for SQL Server Mobile

.NET Compact Framework Data Provider for SQL Server Mobile is used to develop device applications by using the System.Data.SqlClient (namespace of the .NET Compact Framework Data Provider for SQL Server). System.Data.SqlClient in the .NET Compact Framework is a collection of classes that can be used to access SQL Server databases with managed code from Windows CE .NET-based devices.

Sample Code

using System.Data.SqlServerCe;
SqlCeConnection myConnection = new SqlCeConnection();
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
//execute queries
myConnection.Close();

Standard Security

Syntax:

Data Source=urData.sdf;Persist Security Info=False;

Encryption Enabled

Syntax:

Data Source=urData.sdf;Encrypt Database=True;Password=urPassword;File Mode=shared read;

Persist Security Info=False;

Exclusive but Shared for Reading

Syntax:

Data Source=urData.sdf;File Mode=Shared Read;Persist Security Info=False;

Exclusive Access

Syntax:

Data Source=urData.sdf;File Mode=Exclusive;Persist Security Info=False;

Read Only Access

Syntax:

Data Source=urData.sdf;File Mode=Read Only;Persist Security Info=False;

Specification of Maximum Temp file Size

Syntax:

Data Source=urData.sdf;Temp File Max Size=345;Persist Security Info=False;

Specification of location of SDF File

Syntax:

Data Source=" +(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAsse

mbly().GetName().CodeBase) + "\\urData.sdf;Persist Security Info=False;

Specification of Maximum Database Size

Syntax:

Data Source=uyData.sdf;Max Database Size=345;Persist Security Info=False;

Specification of Maximum Buffer Size

Syntax:

Data Source=urData.sdf;Max Buffer Size=1024;Persist Security Info=False;

.NET Framework Data Provider for OLE DB

.NET Framework data provider is used for connecting to a database, executing commands, and retrieving results. Those results are either processed directly, placed in a Dataset in order to be exposed to the user as needed, combined with data from multiple sources, or remoted between tiers. .NET Framework data providers are lightweight, creating a minimal layer between the data source and code, increasing performance without sacrificing functionality.

Sample Code

using System.Data.OleDb;
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
//execute queries
myConnection.Close();

Bridging to Microsoft.SQLSERVER.CE.OLEDB.3.5

Syntax:

Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=urPath\urData.sdf;

Microsoft.SQLSERVER.CE.OLEDB.3.5

Standard Security

Syntax:

Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=urPath\urData.sdf;

Microsoft.SQLSERVER.MOBILE.OLEDB.3.0

Standard Security

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;

Encryption Enabled

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;SSCE:Encrypt Database=True;

Supplying the database password

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;SSCE:Database Password='urPassword';

Specification of Maximum Temp file Size

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;SSCE:Temp File Max Size=345;

Specification of location of Temp File

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;SSCE:Temp File Directory="\urTempDir\";

Specification of location of SDF File

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source="+(System.IO.Path.

GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\urData.sdf;

Specification of Maximum Database Size

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;SSCE:Max Database Size=345;

Specification of Maximum Buffer Size

Syntax:

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=urPath\urData.sdf;SSCE:Max Buffer Size=1024;

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor