如何避免依赖特定的数据库服务器连接 [英] How to avoid dependeing on a specific Data Base Server Connection

查看:59
本文介绍了如何避免依赖特定的数据库服务器连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Folks我又在这里遇到了一个新的存在性疑问,我希望我的应用程序是使用Visual Studio 2010和ADO.NET实体数据模型在C#中开发的,并且独立于数据库服务器连接.
我要说的是,基于现实,应用程序必须部署在不同的环境中,因此在我的特定情况下,以我的Office和Home环境为例.我必须为每个版本都编译一个版本,因为在两种情况下服务器的访问路由都不同,并且安全性也是如此:集成在一个版本上,而另一个则由用户名和密码保护.
我该如何通过外部方式进行配置?也许在应用程序的第一次运行中,但是我如何设置这些属性?.

我正在使用Win Forms而不是Web Forms.

在此先感谢您,我的英语很抱歉.
最好的问候.

Hello Folks i''m here again with a new existential doubt, i want to my application developed in C# with Visual Studio 2010 and ADO.NET Entity Data Model, be independent of the Data Base Server connection.
What i want to say is that based on the reality, the application must be deployed on differents environments, so in my particular case using as example the environments of my Office and my Home. I must compile a version for each one because the access route for the server in both cases vary and the security too: integrated on one and protected by Username and Password on other.
How can i configure that on a external way? Maybe in the first run of the application, but how i set these properties?.

I''m working with Win Forms not Web Forms.

Thanks in advance and sorry for my english.
Best Regards.

推荐答案

我认为您可以通过为不同的服务器使用不同的web.Config文件来解决此问题. 或
使用提供的url作为基础的环境设置,并按照此设置传递连接字符串.
I think you can solve this by using different web.Config files for different servers.
Or
use environment setting based on url supplied and pass connection string as per that.


Pablinff我们在工作中遇到了同样的问题,不仅在家庭与工作之间,而且在我们的开发人员之间(本地)机器和我们的生产服务器.

最后,我们讨论了创建一个通用库的解决方案,该库可以从运行应用程序的计算机上从web.config文件获取设置.

例如,如果要连接到报表服务器,我会说

字符串reportServerName = settings.setting("reportServer")

在web.config中,我们将具有以下appSettings设置

< add key ="dev-reportServer" value ="http://developmentReportServerName">

< add key ="prod-reportServer">
value ="http://productionReportServerName"/>

如果您想了解有关我们如何确定运行应用程序的服务器/机器的更多信息,然后使用它来选择应用程序设置,请回复.

不幸的是,我们正在使用VB.Net,因此您可能不得不忍受我的回答:P
Pablinff we''ve run into the same problem at my work, only not between home and work but between our dev (local) machines and our production servers.

In the end we have gone to the solution of making a common library that gets settings from the web.config file based off the machine the application is running on.

As an example, if I was to connect to the report server I would say

String reportServerName = settings.setting("reportServer")

And in the web.config we would have the following appSettings settings

<add key="dev-reportServer" value="http://developmentReportServerName">

<add key="prod-reportServer">
value="http://productionReportServerName" />

Reply back if you would like more information about how we determine the server/machine that the application is running on and then use that to pick the app setting.

Unfortunately we''re using VB.Net so you might have to suffer my answer in that :P


这篇关于如何避免依赖特定的数据库服务器连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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