我的程序在数据库路径已知时工作正常 但是当我将数据库的安装项目更改路径改为程序路径时
但是当我运行我的程序时会显示此消息
app.config代码是:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ABB.Properties.Settings.ABBagain_CopyConnectionString"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ABB_againCopy-Copy.accdb;Persist Security Info=False;"
providerName="System.Data.OleDb" />
<add name="ABB.Properties.Settings.ABBagain_CopyConnectionString1"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ABB_againCopy-Copy.accdb;Persist Security Info=False;"
providerName="System.Data.OleDb" />
<add name="ABB.Properties.Settings.ABBagain_CopyConnectionString2"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source="C:\Users\Es\Desktop\ABB amr\ABBagain-Copy.accdb""
providerName="System.Data.OleDb" />
<add name="ABB.Properties.Settings.ABB_againCopy_CopyConnectionString"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source="C:\Users\Es\Desktop\final project\ABB_againCopy-Copy.accdb""
providerName="System.Data.OleDb" />
<add name="ABB.Properties.Settings.ABB_againCopy_CopyConnectionString1"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source="C:\Users\AMR\Desktop\final project - Copy (2)\ABB_againCopy-Copy.accdb""
providerName="System.Data.OleDb" />
<add name="ABB.Properties.Settings.ABB_againCopy_CopyConnectionString2"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ABB_againCopy-Copy.accdb;Persist Security Info=False;"
providerName="System.Data.OleDb" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
和连接字符串:
string connString = ConfigurationManager.ConnectionStrings["ABB_againCopy-Copy"].ConnectionString;
答案 0 :(得分:1)
没有名称为ABB_againCopy-Copy
的连接字符串。这就是您收到此错误消息的原因。
此外,您的连接字符串包含大量的绒毛,这使得很难找到合适的连接字符串。
此:
ABB.Properties.Settings.ABB_againCopy_CopyConnectionString1
可能/应该是:
ABB_againCopy-Copy