gpt4 book ai didi

c# - 从 session 将连接字符串分配给表适配器

转载 作者:太空宇宙 更新时间:2023-11-03 18:01:38 25 4
gpt4 key购买 nike

我的应用程序已经开发完毕,现在我们将更改存储在 session 对象中的连接字符串(分布式数据库管理系统 (DDBMS) 的 Bcoz)

问题就在这里......

In that application There are so many **ObjectDataSource** which are

initialize with the using .XSD file. which is related to the TableAdapter and in which connection string of TableAdapter is assign from the Web.Config File. Now How to change the connection string to whatever stored in session object?



提前致谢。

最佳答案

要在运行时更改 XSD 的连接,您需要将表适配器的 ConnectionModifier 属性设置为 Public。如果它们是由“向导”创建的,它们将默认设置为 Friend/Internal (VB/C#)。

我很难找到 ConnectionModifier 属性(它没有在我的 vs2005 文档中列出)!如果单击 XSD 的下部区域(查询所在的位置),那么它应该在属性窗口中可见以进行更改。

然后,您可以在声明表适配器的地方设置 Connection 属性(它需要一个对象而不是字符串)。

关于c# - 从 session 将连接字符串分配给表适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/364962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com