C# 数据访问层DAL.SQLHelper的类型初始值设定项引发异常

火影-信念 火影-信念 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
web.Config配置文件数据库连接代码

<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="SqlConn" connectionString="Data Source=.;User ID=sa;PWD=User@123;DataBase=KvdpContext" providerName="System.Data.SqlClient"/>
<clear />

<add name="Com.Gm.Kvdp.Dao.Frameworks.KvdpContextImpl" connectionString="Server=.;Database=KvdpContext;User Id=sa;Password=User@123" providerName="System.Data.SqlClient" />

</connectionStrings>

C#数据库访问层代码

public sealed partial class SqlHelper
{
#region private utility methods & constructors

// Since this class provides only static methods, make the default constructor private to prevent
// instances from being created with "new SqlHelper()"
// private SqlHelper() { }
static SqlHelper() { }
public static string ConnectionString = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString;
}

...全文

相关推荐

评论 10
收藏 已收藏
分享
返回顶部
火影-信念
C# 111,128 成员 642,536 内容