.NET Compact Framework Data Provider for SQL Server CE
.NET Compact Framework Data Provider for SQL Server Mobile
-
Standard
Data Source=MyData.sdf;Persist Security Info=False;
-
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; -
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;
-
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;
-
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.
SQL Server Compact -
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;
-
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;
-
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;
-
Case sensitive database
Upon database creation the default is case insensitive, use this one for a case sensitive database.
Data Source=MyData.sdf;Case Sensitive=True;Persist Security Info=False;
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
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
2009-08-06 sql server某些数据被误删除如何恢复