加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET web.config文件中的环境变量

发布时间:2020-12-16 06:30:49 所属栏目:asp.Net 来源:网络整理
导读:我想知道为什么我不能在ASP.NET web.config文件中使用自定义环境变量? ?xml version="1.0"?configuration connectionStrings add name="ConnectionName" connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename='%MyProjec
我想知道为什么我不能在ASP.NET web.config文件中使用自定义环境变量?

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="ConnectionName" connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename='%MyProjectsFolder%WebAppNameApp_DataDatabase1.mdf';User Instance=true" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

我查看了开始 – >运行.mdf文件的文件路径是有效的.

当我运行我的C#代码连接到数据库时,我收到以下错误:

An attempt to attach an auto-named database for file
%MyProjectsFolder%WebAppNameApp_DataDatabase1.mdf failed. A
database with the same name exists,or specified file cannot be
opened,or it is located on UNC share.

解决方法

环境变量可能未在配置文件中使用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读