将连接数据库的地址写在web.config里面,后台直接调用

目前除了知道在后台写链接地址,就只会这个方法了!要是有其他更方便的方法希望大家指教!

web.config里的代码

<connectionStrings>
<add name="grv1" connectionString="User id=developer;Password=123456;Database=RCMS;Server=10.10.0.101;Connect Timeout=50;Max Pool size=200;Min pool Size=5" providerName="System.Data.SqlClient" />
</connectionStrings>


后台调用:

  using (SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["grv1"].ConnectionString))
{
     }



原文地址:https://www.cnblogs.com/fuge/p/2423530.html