本文介绍了.net 3.5:从app.config中读取connectionstring?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用.net api从app.config文件读取连接字符串信息?
How to read connection string info from app.config file using .net api?
平台是.net 3.5
Platform is .net 3.5
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add connectionString="" providerName="" name=""/>
</connectionStrings>
</configuration>
推荐答案
请参阅(在原始被删除的Wayback Machine上)
Please see Reading Connection Strings in Web.Config and App.Config and Enterprise Library DAAB Settings (on the Wayback Machine as the original got deleted)
ConnectionStringSettings connection = ConfigurationManager.ConnectionStrings["MyConnectionString"]
string connectionString = connection.ConnectionString
添加程序集引用 System.Configuration
这篇关于.net 3.5:从app.config中读取connectionstring?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!