动态更改连接字符串 [英] change connection string dynamically

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

问题描述



启动时,用户登录并从

下拉列表中选择客户端的名称,然后动态更改连接字符串(

客户端名称表示要使用的数据库。

然后我通过执行以下操作动态更改连接字符串:

My.Settings.Item(" ConnectionString")=" some connection sring"


问题是,如果另一个用户登录并选择另一个

客户端,那么很明显它会改变连接字符串再次和

第一个用户将遇到麻烦!


如何更改连接字符串PER用户?在设置文件中,

连接字符串只能是应用程序级变量,并且由于某种原因,
不能是用户变量:(


谢谢

Hi,
At startup the user log on and chooses the name of a client from a
dropdownlist, which then changes dynamically the connection string (the
name of the client indicates which database to use).
I then change dynamically the connection string by doing :
My.Settings.Item("ConnectionString") = "some connection sring"

The problem is that if another user loggs in and chooses another
client, then obviously it changes the connection string again and the
first user will be in trouble !

How can I change the connection string PER user ? In the setting file,
the connection string can only be an application-level variable and
can''t be a user variable for some reason :(

Thank you

推荐答案

" sam44"< sa ******** *****@googlemail.com写信息

news:11 ******************** @ i42g2000cwa.googlegrou ps.com。 ..
"sam44" <sa*************@googlemail.comwrote in message
news:11********************@i42g2000cwa.googlegrou ps.com...

如何更改连接字符串PER用户?在设置文件中,

连接字符串只能是应用程序 - 级别变量和

由于某种原因不能是用户变量:(
How can I change the connection string PER user ? In the setting file,
the connection string can only be an application-level variable and
can''t be a user variable for some reason :(



设置是什么意思?文件?你的意思是web.config ......?

What do you mean by the "setting" file? Do you mean web.config...?


你好Mark,

不,通过设置文件我的意思是Settings.settings文件,实际上

与app.config文件交互...

任何线索?

Mark Rae写道:
Hi Mark,
No, by setting file I mean the Settings.settings file, which actually
interacts with the app.config file...
Any clue ?
Mark Rae wrote:

" sam44" < sa ************* @ googlemail.comwrote in message

news:11 ***************** ***@i42g2000cwa.googlegrou ps.com ...
"sam44" <sa*************@googlemail.comwrote in message
news:11********************@i42g2000cwa.googlegrou ps.com...

如何更改连接字符串PER用户?在设置文件中,

连接字符串只能是应用程序级变量,并且由于某种原因,
不能是用户变量:(
How can I change the connection string PER user ? In the setting file,
the connection string can only be an application-level variable and
can''t be a user variable for some reason :(



设置文件是什么意思?你的意思是web.config ......?


What do you mean by the "setting" file? Do you mean web.config...?


看起来你正在编写一个Windows窗体应用程序。


如果是这样,你应该将你的问题发布到新闻组:


microsoft.public.dotnet.framework


....在同一台服务器上。


Juan T. Llibre ,asp.net MVP

aspnetfaq.com: http:// www。 aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

============ ====== =================

" sam44" < sa ************* @ googlemail.comwrote in message

news:11 ***************** **** @ b28g2000cwb.googlegro ups.com ...
It looks like you''re writing a Windows Forms App.

If so, you should post your question to the newsgroup:

microsoft.public.dotnet.framework

....on this same server.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"sam44" <sa*************@googlemail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...

嗨Mark,

不,通过设置文件我的意思是设置.settings文件,实际上

与app.config文件交互...

任何线索?


Mark Rae写道:
Hi Mark,
No, by setting file I mean the Settings.settings file, which actually
interacts with the app.config file...
Any clue ?
Mark Rae wrote:

>" sam44" < sa ************* @ googlemail.comwrote in message
新闻:11 ******************** @ i42g2000cwa.googlegro ups.com ...
>"sam44" <sa*************@googlemail.comwrote in message
news:11********************@i42g2000cwa.googlegro ups.com...

如何更改连接字符串PER用户?在设置文件中,

连接字符串只能是应用程序级变量,并且由于某种原因,
不能是用户变量:(
How can I change the connection string PER user ? In the setting file,
the connection string can only be an application-level variable and
can''t be a user variable for some reason :(


设置文件是什么意思?你的意思是web.config ......?


What do you mean by the "setting" file? Do you mean web.config...?



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

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