[英]SQL Server CE: Suppress modifications of database file?
we have an application that has a local SQL Server CE database file. 我们有一个具有本地SQL Server CE数据库文件的应用程序。 When we open the database, but don't do any changes to it, the database file is changed anyway:
当我们打开数据库但不对其进行任何更改时,数据库文件仍然会更改:
using (var connection = new SqlCeConnection("Data Source='data.sdf';File Mode='Shared Read';Encrypt=FALSE;LCID=1033"))
{
connection.Open();
using (var context = new DataContext(connection))
{
}
}
This changes some bytes at the very beginning of the sdf-file. 这会在sdf文件的开头更改一些字节。
Is there any way to prevent this? 有什么办法可以防止这种情况?
Yes, you can enable read only mode in the connection string. 是的,您可以在连接字符串中启用只读模式。 Also you may need to specify a temp path in this case:
另外,在这种情况下,您可能需要指定一个临时路径:
string connectionString = ...;Mode = Read Only;Temp Path= ...;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.