在cs文件中添加数据连接字符串 [英] adding data connection string in cs file

查看:139
本文介绍了在cs文件中添加数据连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用企业库进行数据连接.如何在cs文件中添加连接字符串...无需添加配置..

我的要求是在csharp程序文件中添加连接. .CS文件即可).原因是如果情况或网络拓扑等发生外部变化,则需要修改您的应用程序-这在大多数环境中都是很有可能的.这意味着源必须是可用的,知道源必须是可用的程序员,并且编译器必须是可用的.这不是一件好事,因为它可能意味着大而不必要的延误和中断.

您是否有充分的理由不希望它出现在配置文件中,如果需要可以在此文件中轻松进行修改?


您好,


请通过此链接:

在带有Oracle数据库的ASP.NET 2.0应用程序中使用Enterprise Library 2.0实现动态连接字符串和游标处理的实现 [ ^ ]


i am using enterprise library for data connection.how can i add connection string in cs file... no need of adding in configuration..

my reqirment is adding connection in csharp program file.

解决方案

It is considered a bad idea to "hardwire" any connection string into your application (which is what including it in the .CS file would do). The reason being that your application would need to be modified should an external change in circumstances or network topology etc. occur - which is quite likely in most environments. That means that the source must be available, a programmer who knows the source must be available, and the compiler must be available. This is not a good thing as it can mean big, unnecessary delays and disruption.

Is there a good reason why you do not want this is in a config file, where it can be easily modified if required?


Hello,


Please go through this link :

An Implementation of Dynamic Connection String and Cursor Handling using Enterprise Library 2.0 in an ASP.NET 2.0 Application with an Oracle Database[^]


这篇关于在cs文件中添加数据连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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