连接字符串 - App.Config与Settings.Settings [英] Connection Strings - App.Config vs. Settings.Settings

查看:84
本文介绍了连接字符串 - App.Config与Settings.Settings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


所以这里有一些背景:有可能我们最终会使用两个跟踪系统,用于来自不同客户的呼叫我们还为我们的客户ePortal提供了另一个数据库,该数据库包含来自我们当前主要跟踪数据库的一些信息。为了方便访问所有这些,我一直在使用库来将所有内容组合在一起,并通过此接口管理/创建调用。该库从app.config中提取连接字符串,并认为连接将由当时使用它的任何应用程序定义,这样我们就可以轻松测试并轻松处理数据库移动或更改网络。



我正在改造Windows服务以利用这个库,但它需要一些数据访问将直接来自数据库,因为它是特定于应用程序的。



问题:在为应用程序特定数据创建数据集时,它会在应用程序中创建自己的连接字符串。配置一些自动限定的路径,如:AppName.Properties.Settings.ConnectionStringName而不仅仅是ConnectionStringName。我似乎无法获取数据集来获取我输入的正常连接字符串...这使我不得不将两组连接字符串维护到相同的数据库...



如何解决此问题?

解决方案



我是也有同样的问题。


我有app.config文件,其中我已经提到了连接字符串。


In我的项目我需要交替连接两个数据库。


每次我必须停止应用程序,我必须转到app.config文件,并且必须更改连接字符串,然后将再次运行它。



我想要的是我想要2个文本框应用程序ui和我将每次​​连接字符串userid和passwo rd和应用程序应该使用它来重置app.config文件以连接所需的数据库。



是否可能?那么请建议我如何实现这一目标。



提前致谢


< p align = left> Rupesh Kumar Tiwari


 

So here's some background:  There is/was the possibility that we would end up using two tracking systems for calls from various customers.  We also have another database for our customer ePortal, which ties in some information from our current main tracking database.  To ease access to all of these I've been working on a library to pull everything together and present it for purposes of managing/creating calls through this interface.  This library pulls connection strings from app.config, with the idea that the connections will be defined by whatever application is using it at the time, so that we can ease testing and easily handle database moves or changing networks. 

 

I'm retrofitting a windows service to make use of this library, but some of the data it will need to access will come directly from the databases since it is application specific. 

 

The problem:  When creating the datasets for the application specific data, it creates it's own connection strings in app.config with some automatically qualified path like: AppName.Properties.Settings.ConnectionStringName rather than just ConnectionStringName.  I can't seem to get the data sets to pick up the normal connection strings I entered... which leaves me having to maintain two sets of connection strings to the same databases...

 

How do I fix this?

解决方案

Hi,

I am also having the same kinda problem.

I have app.config file where i have already mentioned connection string.

In my project i need to connect two database alternately.

for that each time i have to stop the application and i have to go to the app.config file and have to change the connection string and then will have to run it again.

 

What i want is i want to have 2 textboxes on the application ui and i will put each time connection strings userid and password and application should take this for reseting the app.config file to connect the desired database.

 

Is it possible? then please suggest me how i can accomplish this.

 

Thanks in advance

Rupesh Kumar Tiwari


这篇关于连接字符串 - App.Config与Settings.Settings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆