【发布时间】:2011-11-16 18:36:31
【问题描述】:
我正在使用 bin/debug 文件夹中的 access db,并在类似代码中使用它
private static string **_strCon** = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
***Application.ExecutablePath.ToString().Substring(0,
Application.ExecutablePath.ToString().LastIndexOf('\\')) +
"\\Reporting.accdb***;Jet
OLEDB:Database Password=abc;";
对于报告,我使用 DataSet,它使用 app.config 中的连接字符串,例如
<add name="GarzaReportingSystem.Properties.Settings.ReportingConnectionString"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;***Data Source=|DataDirectory|\bin
\Debug\Reporting.accdb***;Persist Security Info=True;Jet OLEDB:Database Password=abc" providerName="System.Data.OleDb"/>
问题:
当我设置项目并安装应用程序时。我需要将 Reporting.accdb 放在根文件夹中,以便我的表单使用 _strCon 工作。换句话说,我的可执行文件路径成为根文件夹
但对于数据集
我需要将 access db 放在 bin/debug 文件夹中,以便在安装应用程序时它可以工作。
如何解决这个问题,使两者都解决相同的路径,如 root 有文件夹 DataBase 并且都使用该路径。
【问题讨论】:
-
在创建安装文件时在“应用程序文件夹”中添加 .accdb 文件
-
@deepi ,这意味着我需要在进行设置时始终将 app.config 路径更改为 root ? .因为当我准备设置时 app.config 路径不起作用。