如何在不将配置文件添加到库项目的情况下与数据库建立连接 [英] How to make connection with Database Without Adding Config File to LIbrary Project

查看:84
本文介绍了如何在不将配置文件添加到库项目的情况下与数据库建立连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

如何在不向数据库项目添加配置文件的情况下与数据库建立连接

问候
Suresh

Hello All

How to make connection with Database Without Adding Config File to LIbrary Project

Regards
Suresh

推荐答案

您可以对连接字符串进行硬编码,不推荐使用.
您可以在应用启动时要求提供连接详细信息.
如果您的项目是DLL,则可以从调用应用程序将其传递.

对我来说,真正的问题是为什么您不想要它在配置文件中?
如果是因为它是纯文本格式,则对连接字符串进行加密,然后在使用时对其进行解密,并仅允许在您的应用程序内部对其进行更改.
Well you can hard code the connection string, not recommended.
You could ask for the connection details when your app starts.
If your project is a DLL you could pass it in from the calling app.

The real question for me is why don''t you want it in the config file?
If it is because it is plain text then encrypt the connection string then decrypt it when you use it and only allow it to be changed from within your app.


这篇关于如何在不将配置文件添加到库项目的情况下与数据库建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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