我的访问数据库放在计算机的哪里 [英] where to put my access database in computer
问题描述
我刚刚在Visual Basic 2010中完成了我的项目.我正在使用MS Access作为数据库.
I've just finished my project in Visual Basic 2010. I'm using MS Access as my database.
我已将其保存在文档中并连接到我的项目.我没有复制它进行调试.
I've saved it in my documents and connected to my project. I didn't copy it to debug.
现在,当我创建安装程序并将其安装到另一台计算机时,会发生错误,因为它找不到我的数据库.手动将数据库复制到另一台计算机即可解决此问题.
Now when I create an installer and install it to another computer, an error occurs because it couldn't find my database. Manually copying my database to the other computer solves the problem.
c:\users\users\documents\database.accdb
问题是如何创建包含数据库的安装程序?我应该把数据库放在哪里?将我的数据库放在用户文件夹中使其变为只读.
The problem how could I create an installer including my database? And where should I put my database? Putting my database in the user folder makes it read only.
我使用Visual Studio安装程序,安装项目.谢谢你的帮助
I use Visual Studio installer, setup project. thanks for your help
推荐答案
我的个人观点是安装程序不应创建每个用户的数据或对象.您的应用程序的可执行文件(而不是安装程序)应该是创建.accdb
文件(或从应位于%programfiles%
的只读模板文件中复制)的可执行文件.
My personal philosophy is that installers should not create per-user data or objects. Your application's executable, not the installer, should be the one that creates the .accdb
file (or copies it from a read-only template file which should be in %programfiles%
).
如果数据库是按用户使用的,并且不应由用户直接操作,则它应位于%appdata%\YourCompany\YourProduct\
或(如果不漫游的情况下,应为%localappdata%
)而不是My Documents
.
If the database is per-user and should not be manipulated by users directly then it should go under %appdata%\YourCompany\YourProduct\
or (%localappdata%
if it shouldn't roam) instead of My Documents
.
如果数据库由多个用户共享,则它应位于%programdata%
(又名%allusersprofile%
)下.
If the database is shared by multiple users, then it should go under %programdata%
(aka %allusersprofile%
).
做这样的事情:
- 在安装过程中不要安装"
.accdb
文件. - 相反,可以:
- Do not "install" the
.accdb
file during installation. - Instead, either:
- 在软件代码中使用ADO的
CreateDatabase
. - 或者在程序的安装目录中(位于
%programfiles%\You
下)有一个只读的模板/原型数据库.
- Use ADO's
CreateDatabase
in your software code. - Or have a read-only template/prototype database in your Program's installation directory (under
%programfiles%\You
)
- 在应用程序启动时,检查
%appdata%\You\Foo.accdb
文件是否存在 - 如果不是,请使用
File.Copy
将文件从%programfiles%\You
复制到%appdata%
) - 并清除只读标志
- On application start-up, check to see if the
%appdata%\You\Foo.accdb
file exists - If not, use
File.Copy
to copy the file from%programfiles%\You
to%appdata%
) - And clear the read-only flag
这篇关于我的访问数据库放在计算机的哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!