Fetching connection string from appconfig file in c#

前端 未结 10 978
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 07:39

I have the following connection string declared in my app.config file:

  
    

        
10条回答
  •  -上瘾入骨i
    2020-12-19 08:03

    there is another way to do this for console app:

        
      
        
      
    

    to read it

    using System.Configuration;
    

    and then use

    string CONSTRING;
    AppSettingsReader ap = new AppSettingsReader();
    CONSTRING = ap.GetValue("SqlConString",typeof(string)).ToString();
    

提交回复
热议问题