I have a program in C# that uses an MS Access database and I'm using OleDb to connect and do queries on that database. My issue is that I have some sensitive info in the database and I don't want it to appear as an Access DB. I changed the extension, but when I open it, it still creates the .ldb lock file used by Access. I want to have the DB not create that lock file.
我在C#中有一个使用MS Access数据库的程序,我使用OleDb连接并对该数据库进行查询。我的问题是我在数据库中有一些敏感信息,我不希望它显示为Access DB。我更改了扩展名,但是当我打开它时,它仍然会创建Access使用的.ldb锁定文件。我想让DB不创建该锁文件。
I have read many posts on the issue and it sounds like if I open the DB in Exclusive mode, it will not create that .ldb file. However, so far, I have not found any connection string for OleDb that lets me specify Exclusive access to the DB. The OleDbConnection object in C# has no "Mode" member either, so setting exclusive access that way is out of the question.
我已经阅读了很多关于这个问题的帖子,听起来好像我在独家模式下打开数据库,它不会创建.ldb文件。但是,到目前为止,我还没有找到OleDb的任何连接字符串,它允许我指定对DB的独占访问权限。 C#中的OleDbConnection对象也没有“模式”成员,因此以这种方式设置独占访问是不可能的。
If anyone has any connection strings that can open the DB in Exclusive mode, or if anyone knows another way to avoid creating the .ldb lock file in Access, the help would be much appreciated.
如果任何人有任何连接字符串可以在独占模式下打开数据库,或者如果有人知道另一种方法来避免在Access中创建.ldb锁定文件,那么将非常感谢帮助。
6 个解决方案
#1
http://www.connectionstrings.com/access has an entry for Ecxlusive mode.
http://www.connectionstrings.com/access有一个Ecxlusive模式的条目。
#2
I would recommend using SQLite or another non-access option if you want to avoid lock files.
如果你想避免锁定文件,我建议使用SQLite或其他非访问选项。
Trying to avoid the lock files is difficult at best. Even if you open the file in exclusive mode, JET creates these files at times.
试图避免锁定文件是最困难的。即使您以独占模式打开文件,JET有时也会创建这些文件。
If you're trying to store sensitive data, and you want to "hide" the type of file, another good option is VistaDB. It's a single file database, but allows full DB encryption. This would probably be a better approach than just trying to mask the fact you're using JET.
如果您正在尝试存储敏感数据,并且想要“隐藏”文件类型,则另一个不错的选择是VistaDB。它是单个文件数据库,但允许完全DB加密。这可能是一个更好的方法,而不仅仅是试图掩盖你正在使用JET的事实。
#3
You can't really hide that it's an Access database. Anyone can open the file in a hex editor (or even just notepad) and see a string like "Standard Jet DB
" (Office 2000/XP/2003) or "Standard ACE DB
" (Office 2007) staring right at them. Even if they don't know what that means Google will tell them soon enough. You use could a less-common database, but they will have similar weaknesses.
你无法真正隐藏它是一个Access数据库。任何人都可以在十六进制编辑器(甚至只是记事本)中打开文件,并看到像“标准Jet DB”(Office 2000 / XP / 2003)或“标准ACE DB”(Office 2007)这样的字符串。即使他们不知道这意味着谷歌会尽快告诉他们。你可以使用一个不太常见的数据库,但它们会有类似的弱点。
If you really want security, you're going to have to encrypt the database file and use an engine that will let you keep a decrypted version in memory (IIRC sqlite supports this, or will soon) or use an engine that supports encryption natively. Even then, you can have problems if the ram is paged to disc or if another process "sniffs" your app's ram.
如果你真的想要安全性,你将不得不加密数据库文件,并使用一个引擎,让你在内存中保存一个解密版本(IIRC sqlite支持这个,或者很快)或者使用一个本机支持加密的引擎。即使这样,如果ram被分页到光盘或者另一个进程“嗅探”你的应用程序的ram,你可能会遇到问题。
A late update, but my attention was drawn back here today and I wanted to add that just about anything but Access will require you to distribute the engine with the application. You need to also take care that the files for the engine don't give it away as well. Access gets a pass because the engine is already part of windows. You might also try something that's open source, so you can re-compile it into your main application file.
最近的更新,但今天我的注意力被提到了这里,我想添加几乎任何东西,但Access将要求你使用应用程序分发引擎。您还需要注意引擎的文件也不要放弃它。 Access获得通过,因为引擎已经是Windows的一部分。您也可以尝试一些开源的东西,这样您就可以将它重新编译到主应用程序文件中。
#4
I have several databases with the Exclusive flag set, and I still get .ldb files created each time I open one. If you are really worried about security it's time to move to a 'grown-up' database.
我有几个数据库设置了Exclusive标志,每次打开一个时我仍然会创建.ldb文件。如果你真的担心安全性,那么就该转向“成熟”的数据库了。
#5
Install SQL Server 2008 Express, use upsize wizard in Access, point to your Express instance.
安装SQL Server 2008 Express,在Access中使用upsize向导,指向Express实例。
#6
You could also potentially use Sql Server Compact to do this. It is free and part of Visual Studio. It is actively used by Microsoft in quite a few products, including Windows Live.
您也可以使用Sql Server Compact来执行此操作。它是免费的,是Visual Studio的一部分。它在很多产品中都被积极使用,包括Windows Live。
#1
http://www.connectionstrings.com/access has an entry for Ecxlusive mode.
http://www.connectionstrings.com/access有一个Ecxlusive模式的条目。
#2
I would recommend using SQLite or another non-access option if you want to avoid lock files.
如果你想避免锁定文件,我建议使用SQLite或其他非访问选项。
Trying to avoid the lock files is difficult at best. Even if you open the file in exclusive mode, JET creates these files at times.
试图避免锁定文件是最困难的。即使您以独占模式打开文件,JET有时也会创建这些文件。
If you're trying to store sensitive data, and you want to "hide" the type of file, another good option is VistaDB. It's a single file database, but allows full DB encryption. This would probably be a better approach than just trying to mask the fact you're using JET.
如果您正在尝试存储敏感数据,并且想要“隐藏”文件类型,则另一个不错的选择是VistaDB。它是单个文件数据库,但允许完全DB加密。这可能是一个更好的方法,而不仅仅是试图掩盖你正在使用JET的事实。
#3
You can't really hide that it's an Access database. Anyone can open the file in a hex editor (or even just notepad) and see a string like "Standard Jet DB
" (Office 2000/XP/2003) or "Standard ACE DB
" (Office 2007) staring right at them. Even if they don't know what that means Google will tell them soon enough. You use could a less-common database, but they will have similar weaknesses.
你无法真正隐藏它是一个Access数据库。任何人都可以在十六进制编辑器(甚至只是记事本)中打开文件,并看到像“标准Jet DB”(Office 2000 / XP / 2003)或“标准ACE DB”(Office 2007)这样的字符串。即使他们不知道这意味着谷歌会尽快告诉他们。你可以使用一个不太常见的数据库,但它们会有类似的弱点。
If you really want security, you're going to have to encrypt the database file and use an engine that will let you keep a decrypted version in memory (IIRC sqlite supports this, or will soon) or use an engine that supports encryption natively. Even then, you can have problems if the ram is paged to disc or if another process "sniffs" your app's ram.
如果你真的想要安全性,你将不得不加密数据库文件,并使用一个引擎,让你在内存中保存一个解密版本(IIRC sqlite支持这个,或者很快)或者使用一个本机支持加密的引擎。即使这样,如果ram被分页到光盘或者另一个进程“嗅探”你的应用程序的ram,你可能会遇到问题。
A late update, but my attention was drawn back here today and I wanted to add that just about anything but Access will require you to distribute the engine with the application. You need to also take care that the files for the engine don't give it away as well. Access gets a pass because the engine is already part of windows. You might also try something that's open source, so you can re-compile it into your main application file.
最近的更新,但今天我的注意力被提到了这里,我想添加几乎任何东西,但Access将要求你使用应用程序分发引擎。您还需要注意引擎的文件也不要放弃它。 Access获得通过,因为引擎已经是Windows的一部分。您也可以尝试一些开源的东西,这样您就可以将它重新编译到主应用程序文件中。
#4
I have several databases with the Exclusive flag set, and I still get .ldb files created each time I open one. If you are really worried about security it's time to move to a 'grown-up' database.
我有几个数据库设置了Exclusive标志,每次打开一个时我仍然会创建.ldb文件。如果你真的担心安全性,那么就该转向“成熟”的数据库了。
#5
Install SQL Server 2008 Express, use upsize wizard in Access, point to your Express instance.
安装SQL Server 2008 Express,在Access中使用upsize向导,指向Express实例。
#6
You could also potentially use Sql Server Compact to do this. It is free and part of Visual Studio. It is actively used by Microsoft in quite a few products, including Windows Live.
您也可以使用Sql Server Compact来执行此操作。它是免费的,是Visual Studio的一部分。它在很多产品中都被积极使用,包括Windows Live。