Connection strings for SQL Server Compact
.NET libraries for SQL Server Compact
- .NET Compact Framework Data Provider for SQL Server Mobile - SqlCeConnection
- .NET Framework Data Provider for OLE DB - OleDbConnection
OLE DB providers for SQL Server Compact
.NET Compact Framework Data Provider for SQL Server Mobile
Usage System.Data.SqlServerCe.SqlCeConnection
Manufacturer Microsoft
Standard
How to specify the location of the SDF file
Often times the .SDF database is not running in the current directory so it becomes necessary to programatically set the path to the SDF file. This is an example (.net C#) on how to do this when the SDF file is located in the same directory as the executing application.
Standard
Specifying the maximum database size
The maximum size of the database is by default 128 MB. Override this by using the following connection string.
Specifying the maximum buffer size
The largest amount of memory that can be in use before the server starts flushing changes to disk is by default 640 kB. Override this by using the following connection string.
Encryption enabled
Use this connection string to enable encryption on the database.
The Encrypt Database="True" pair is really not necessary as the presence of the Password-parameter itself turns on encryption for the connection.
Exclusive access
Use this one to disallow other processes from opening or modifying the database while you have it open.
Read only access
Use this one to open a read-only copy of the database.
Exclusive but shared for reading
Use this one to allow other processes to read, but not modify, the database while you have it open.
Specifying the maximum temp file size
The maximum size of the temporary database file is by default 128 MB. Override this by using the following connection string.
Case sensitive database
Upon database creation the default is case insensitive, use this one for a case sensitive database.
This allows you to have multiple values, wich only deffer in lower / upper case, in a unique column.
This setting is a database creation time option and is ignored when connecting to an existing database.
Microsoft.SQLSERVER.CE.OLEDB.3.5
Usage Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5
Manufacturer Microsoft
Microsoft.SQLSERVER.MOBILE.OLEDB.3.0
Usage Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0
Manufacturer Microsoft
Standard
How to specify the location of the SDF file
Often times the .SDF database is not running in the current directory so it becomes necessary to programatically set the path to the SDF file. This is an example (.net C#) on how to do this when the SDF file is located in the same directory as the executing application.
Specifying the maximum database size
The maximum size of the database is by default 128 MB. Override this by using the following connection string.
Specifying the maximum buffer size
The largest amount of memory that can be in use before the server starts flushing changes to disk is by default 640 kB. Override this by using the following connection string.
Encryption enabled
Use this connection string to enable encryption on the database.
Specifying the maximum temp file size
The maximum size of the temporary database file is by default 128 MB. Override this by using the following connection string.
Specifying location of temp file
Set the directory for the temp file location using this connection string.
Supplying the database password
Use this connection string to provide the database password when opening the connection.
.NET Framework Data Provider for OLE DB
Usage System.Data.OleDb.OleDbConnection
Manufacturer Microsoft
Use an OLE DB provider from .NET
See the respective OLEDB provider's connection strings options. The .net OleDbConnection will just pass on the connection string to the specified OLEDB provider. Read more here.