在运行时更改web.config中特定会话的连接字符串 [英] Change connection string in web.config at runtime for particular session

查看:78
本文介绍了在运行时更改web.config中特定会话的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

在我的项目中,我必须为不同的用户连接不同的数据库.因此,我需要知道如何在运行时更改特定会话的web.config中的连接字符串.

我的情况就是这样.

任何用户都将使用其登录ID和密码登录并从下拉列表中选择公司名称,然后从数据库中检索适当的详细信息即表示其连接字符串"或数据库详细信息".
之后,我必须根据他的数据库详细信息更改web.config中的连接字符串.因为不同公司的每个用户都有不同的数据库.

注意:
我在项目中使用Microsoft Enterprise库进行数据库连接.因此,我需要在web.config文件中暂停连接字符串键,也可以在后面的代码中传递它.

请帮助我..

Hello friends,

In my project there is a requirement that I have to connect different databases for different users. So for that I need to know how can I change connection string in web.config at runtime for particular session.

My Scenario is like this.

Any user come and login with his login ID and Password and Select Company Name from the drop down list after that we retrieve proper details from the database means his "Connection String" or "Database Details".
After that I have to change the connection string in web.config according to his database details. Because Every user of different company have different database.

Note:
I''m using Microsoft Enterprise library for database connection in my project. So I need to paas connection string key in web.config file or I can pass it on code behind as well.

Please Help me in this..

推荐答案

您不必在运行时更改web.config.您可以使用不同的名称存储所有连接字符串,然后根据登录用户选择所需的字符串.
You don''t have to change web.config at runtime. You could store all connection strings with different names and select the one you need depending on logged in user.


这篇关于在运行时更改web.config中特定会话的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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