通过ado.net访问数据访问层中的连接字符串时出错

时间:2019-07-05 17:16:09

标签: asp.net-mvc-4

在web.config中添加连接字符串并在数据访问层中访问它之后,它将引发异常 用户代码未处理typeinitialization异常

<connectionStrings>
    <add name="BO"
    connectionString="Data Source=DESKTOP-921J2S6\\SQLEXPRESS;Initial Catalog=CRUD;User ID=sa;Password=password-1;Integrated Security=False"
    providerName="System.Data.SqlClient" />
  </connectionStrings>

static string databaseConnection = ConfigurationManager.ConnectionStrings["BO"].ConnectionString;
 SqlConnection con = new SqlConnection(databaseConnection);

0 个答案:

没有答案