.net 3.5: To read connectionstring from app.config?

后端 未结 4 686
无人及你
无人及你 2020-12-17 19:37

How to read connection string info from app.config file using .net api?

Platform is .net 3.5

     
          


        
4条回答
  •  北海茫月
    2020-12-17 19:54

    If name is a string value that represents the name of the connection string:

    var connectionString = 
        ConfigurationManager.ConnectionStrings[name].ConnectionString;
    

    In your example you didn't provide a value for name, so you'll have to do that before it'll work.

提交回复
热议问题