Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 配置部分';连接字符串';无法读取,因为它缺少节声明_C#_C# 4.0_Database Connection_Connection String - Fatal编程技术网

C# 配置部分';连接字符串';无法读取,因为它缺少节声明

C# 配置部分';连接字符串';无法读取,因为它缺少节声明,c#,c#-4.0,database-connection,connection-string,C#,C# 4.0,Database Connection,Connection String,我正在尝试将我的网页(c#)移动到ISS 7.5服务器 我已经读到,我需要在WEBCONFIG中加入,以实现与sql server 2008的连接 我已经做到了 这是我的网络配置 <?xml version="1.0" encoding="UTF-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com

我正在尝试将我的网页(c#)移动到ISS 7.5服务器

我已经读到,我需要在WEBCONFIG中加入,以实现与sql server 2008的连接

我已经做到了

这是我的网络配置

<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionstrings>
   <!-- <remove name="LocalSqlServer" /> -->
    <add name="conexionsql" connectionstring="Data Source=FCH-DESARROLLO;Initial Catalog=DesaInterno;Integrated Security=True;User ID=usuario_de_conexion;Password=a"
     providerName="System.Data.SqlClient"/>
  </connectionstrings> 


  <system.web>

    <!--<identity impersonate="true" /> -->

    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <!--  <add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> -->
        <add assembly="*" />
      </assemblies>
    </compilation>
   <!-- <httpRuntime targetFramework="4.5"/> -->
  <!--  <authentication mode="Windows" /> -->
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>


 <!-- <system.webServer> -->
   <!-- <defaultDocument>
      <files>
        <add value="index.aspx" />
      </files>
    </defaultDocument> -->

  <!--</system.webServer> -->
   <!-- <connectionStrings>
        <remove name="LocalSqlServer" />
        <add connectionString="Server=10.10.201.79;Database=DesaInterno;Integrated Security=true" name="LocalSqlServer" />
    </connectionStrings> -->
</configuration>

当我尝试在IIS中运行我的应用程序时,出现了一个错误

错误HTTP 500.19-配置部分出现内部服务器错误 无法读取“ConnectionString”,因为它缺少节 声明


连接字符串部分具有以下定义,区分大小写:

<connectionStrings>
     <add name="conexionsql" connectionstring="Data Source=FCH-DESARROLLO;Initial Catalog=DesaInterno;Integrated Security=True;User ID=usuario_de_conexion;Password=a"
 providerName="System.Data.SqlClient"/>
</connectionStrings>

这是因为键区分大小写,并且所有连接字符串都是小写的,只需更改为正确的大小写连接字符串(注意大写的S

完整配置(删除冗余项)现在如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="conexionsql" connectionstring="Data Source=FCH-DESARROLLO;Initial Catalog=DesaInterno;Integrated Security=True;User ID=usuario_de_conexion;Password=a"
     providerName="System.Data.SqlClient"/>
  </connectionStrings> 

  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="*" />
      </assemblies>
    </compilation>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</configuration>



用上述配置替换您的代码

此外,标签应在适当的情况下准确给出

让我知道,如果你仍然坚持它可能是一些其他问题

  <configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <connectionStrings>
      <add name="#" connectionString="#" providerName="System.Data.SqlClient"/>
    </connectionStrings>
  </configuration>