Add connectionstring in app.config

后端 未结 6 1862
Happy的楠姐
Happy的楠姐 2020-12-17 07:05

I have a class library in C# has has several classes and a app.config. I have put ConnectionString in app.config as follows:


    &l         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 07:48

    In windows forms applications always add reference to System.Configuration in References then in the code page add using System.Configuration then use the connection strings like this:

    string conStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
    

提交回复
热议问题