how to get connection string from app config in c#

后端 未结 2 1351
北荒
北荒 2020-12-22 14:27

My app.config file:


    
        

        
2条回答
  •  暖寄归人
    2020-12-22 15:07

    try

    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringNameFromWebConfig"].ConnectionString);
    

    It should work

提交回复
热议问题