Connection strings for SQL Server Compact Edition

來源:互聯網
上載者:User
文章目錄
  • Standard
  • How to specify the location of the SDF file
  • Standard
  • Specifying the maximum database size
  • Specifying the maximum buffer size
  • Encryption enabled
  • Exclusive access
  • Read only access
  • Exclusive but shared for reading
  • Specifying the maximum temp file size
  • Standard
  • Standard
  • How to specify the location of the SDF file
  • Specifying the maximum database size
  • Specifying the maximum buffer size
  • Encryption enabled
  • Specifying the maximum temp file size
  • Specifying location of temp file
  • Supplying the database password
  • Bridging to Microsoft.SQLSERVER.CE.OLEDB.3.5
.NET Compact Framework Data Provider for SQL Server MobileType .NET Framework Class Library
Usage System.Data.SqlServerCe.SqlCeConnection
Manufacturer Microsoft
Set example values »

More about this class library »StandardData Source=MyData.sdf;Persist Security Info=False; Copy 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.

Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyData.sdf;Persist Security Info=False; Copy StandardData Source=MyData.sdf;Persist Security Info=False; Copy Specifying the maximum database size

The maximum size of the database is by default 128 MB. Override this by using the following connection string.

Data Source=MyData.sdf;Max Database Size=256;Persist Security Info=False; Copy 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.

Data Source=MyData.sdf;Max Buffer Size=1024;Persist Security Info=False; Copy Encryption enabled

Use this connection string to enable encryption on the database.

Data Source=MyData.sdf;Encrypt Database=True;Password=myPassword;File Mode=shared read;Persist Security Info=False;

The Encrypt Database="True" pair is really not necessary as the presence of the Password-parameter itself turns on encryption for the connection.

 

Copy Exclusive access

Use this one to disallow other processes from opening or modifying the database while you have it open.

Data Source=MyData.sdf;File Mode=Exclusive;Persist Security Info=False;  Read only access

Use this one to open a read-only copy of the database.

Data Source=MyData.sdf;File Mode=Read Only;Persist Security Info=False; Copy Exclusive but shared for reading

Use this one to allow other processes to read, but not modify, the database while you have it open.

Data Source=MyData.sdf;File Mode=Shared Read;Persist Security Info=False; Copy 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.

Data Source=MyData.sdf;Temp File Max Size=256;Persist Security Info=False; Copy Microsoft.SQLSERVER.CE.OLEDB.3.5Type OLE DB Provider
Usage Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5
Manufacturer Microsoft
Set example values »

More about this provider »StandardProvider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=myPath\myData.sdf; Copy Microsoft.SQLSERVER.MOBILE.OLEDB.3.0Type OLE DB Provider
Usage Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0
Manufacturer Microsoft
Set example values »

More about this provider »StandardProvider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf; Copy 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.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyData.sdf; Copy Specifying the maximum database size

The maximum size of the database is by default 128 MB. Override this by using the following connection string.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf;SSCE:Max Database Size=256; Copy 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.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf;SSCE:Max Buffer Size=1024; Copy Encryption enabled

Use this connection string to enable encryption on the database.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf;SSCE:Encrypt Database=True; Copy 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.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf;SSCE:Temp File Max Size=256; Copy Specifying location of temp file

Set the directory for the temp file location using this connection string.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf;SSCE:Temp File Directory="\myTempDir\"; Copy Supplying the database password

Use this connection string to provide the database password when opening the connection.

Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=myPath\myData.sdf;SSCE:Database Password='myPassword'; Copy .NET Framework Data Provider for OLE DBType .NET Framework Wrapper Class Library
Usage System.Data.OleDb.OleDbConnection
Manufacturer Microsoft
Set example values »

More about this wrapper class library »Bridging to Microsoft.SQLSERVER.CE.OLEDB.3.5

This is just one connection string sample for the wrapping OleDbConnection class that calls the underlying OLEDB provider. See respective OLE DB provider for more connection strings to use with this class.

Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=myPath\myData.sdf; Copy Sign-in or Join

ShareSelected ArticlesWhat is a connection string?Rules for connection stringsAll SQL Server SqlConnection propertiesSQL Server Data Types Reference 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.