将MS Access DB文件保留在项目文件夹中的位置. [英] Where to keep the MS Access DB file in the project folder.

查看:131
本文介绍了将MS Access DB文件保留在项目文件夹中的位置.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用vc#中的项目来连接到MS Access db.我的项目快要完成了,但是我遇到一个问题,就是每当我将项目携带到另一个系统时,我都需要保持它与我在系统上的路径相同的路径(例如:在我的系统中,我将该项目放在文件夹D下:\ proj.)因此,在每个系统上,我只需要将项目保持在此位置即可.

请告诉我应该存放数据库的确切位置,以便为我提供帮助,以便每当我将项目运送到另一个系统时,它与我存放数据库的位置无关都可以正常工作.

:(

还请告诉我它的连接字符串.

Bye

Hello everyone,

I m working on the project in vc# connecting to MS Access db. My project is almost complete but i m facing a problem that whenever i m carrying my project to another system i need to keep it 2 the same path as i had it at my system(eg: in my system i have made this project under the folder D:\proj.) So on each and every system i need to keep my project under this location only.

Please assist me by telling the exact location where i should keep my DB so that whenever i m carrying my project to another system, it should work fine irrelevant of the location where i have kept it.

:(

Also Please tell me the connection string for it.

Bye

推荐答案

我建​​议您使用以下其中一项:
1.在应用程序文件夹(您的exe文件所在的位置)中:然后可以编写如下:.\mydb
2.在User \ AppData文件夹中.您可以使用Google并找到使用方法.
I would advice you one of the following:
1. In the application folder (where your exe is located): then you can write as follows: .\mydb
2. In the User\AppData folder. You can use google and find how to use it.


我想您可能会创建一个将db放置到目标位置的安装程序.

或者,您也可以使用app.config定义文件所在的路径.

通常,我们将数据库文件放置在相同的文件夹中以具有更好的访问权限.您也可以使用任何路径.只需将其放置在所需的任何位置,然后使用文件路径编辑app.config:

I think you might create one installer that places the db to the target location.

Or you might also use app.config to define the path of the file where it is located.

Generally we place the database file in the same folder as to have better access. You might also use any path. Just place it anywhere where you want and edit app.config with path of the file:

<br />
<appSettingss><br />
<add key="dbPath" Value="C:\x\y\db.mdb">




现在,在您的代码中,将连接字符串中的文件路径替换为
ConfigurationSettings.AppSettings ["dbPath"];

:thumbsup:




Now in your code replace the filepath in the connection string with
ConfigurationSettings.AppSettings ["dbPath"];

:thumbsup:


这篇关于将MS Access DB文件保留在项目文件夹中的位置.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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