我的访问数据库放在计算机的哪里 [英] where to put my access database in computer

查看:46
本文介绍了我的访问数据库放在计算机的哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在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%).

做这样的事情:

  1. 在安装过程中不要安装" .accdb文件.
  2. 相反,可以:
  1. Do not "install" the .accdb file during installation.
  2. Instead, either:
  1. 在软件代码中使用ADO的CreateDatabase.
  2. 或者在程序的安装目录中(位于%programfiles%\You下)有一个只读的模板/原型数据库.
  1. Use ADO's CreateDatabase in your software code.
  2. Or have a read-only template/prototype database in your Program's installation directory (under %programfiles%\You)
  1. 在应用程序启动时,检查%appdata%\You\Foo.accdb文件是否存在
  2. 如果不是,请使用File.Copy将文件从%programfiles%\You复制到%appdata%)
  3. 并清除只读标志
  1. On application start-up, check to see if the %appdata%\You\Foo.accdb file exists
  2. If not, use File.Copy to copy the file from %programfiles%\You to %appdata%)
  3. And clear the read-only flag

这篇关于我的访问数据库放在计算机的哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆