WinForm(C#) 引用app.config文件中的数据库

app.config   中一部份代码

<configuration>

<appSettings>    //注意要加上这个,否责会报错,“什么为能初始化之类”

<add key="ConnSqlStr" value="数据库链接字段"/>  

                                                     //  要用像 web开发似的(web.config)中还要加providerName这个数据库提供者,否责一样报错

</appSettings>

</configuration>

引用:

            string conn = configuration.configurationSettings.AppSettings["ConnSqlStr"].tostring();

 sqlconnection con = new sqlconnection(conn);

初学者,自己的写法,如有不对,多多包涵

原文地址:https://www.cnblogs.com/server126/p/2290660.html