代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="server" connectionString="localhost"></add>
<add name="database" connectionString="housing"></add>
<add name="login" connectionString="root"></add>
<add name="password" connectionString="root"></add>
</connectionStrings>
</configuration>
获取配置文件的方式
private static string server = ConfigurationManager.ConnectionStrings["server"].ConnectionString;
private static string database = ConfigurationManager.ConnectionStrings["database"].ConnectionString;
private static string login = ConfigurationManager.ConnectionStrings["login"].ConnectionString;
private static string password = ConfigurationManager.ConnectionStrings["password"].ConnectionString;
————————————————
版权声明:本文为CSDN博主「明明如月学长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/w605283073/article/details/43671971