组态 [英] Configuration
本文介绍了组态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
刚刚看到这段代码:
Dim config As Configuration
config = ConfigurationManager .OpenExeConfiguration(ConfigurationUserLevel.None)
返回config.ConnectionStrings.ConnectionStrings(key).ConnectionString
如果我是编译器要求编译它,我会自我破坏并带走我的所有代码!
无论发生什么事情
My.Settings.MyConnectionString
Mary
解决方案
我认为这里的原因是为了访问配置文件中的多个连接之一,而当只有一个连接时使用My.Settings.SomeConnection。
Just came across this code:
Dim config As Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) Return config.ConnectionStrings.ConnectionStrings(key).ConnectionString
If I were a compiler asked to compile that, I would self-destruct and take all your code with me!
Whatever happened to
My.Settings.MyConnectionString
Mary
解决方案
I believe the reason here is for accessing one of many connections in the config file while when there is only one connection we use My.Settings.SomeConnection.
See my MSDN code sample for multiple connections in one project. Then there is sharing connections across projects as shown in my MSDN code sample.
这篇关于组态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文