开发者

ASP.NET - dynamically creating database connection in datasets

I am currently using datasets for my data access layer. I currently store the connection string in the web.config file. I need the ability to change the connection to another database before any queries are processed. Is there an event that is trigger开发者_运维百科ed or a base class that can be modified that intercepts the process of retrieving the connection string from the web.config file? Is there any way to handle multiple database connections using the same code base and also take advantage of the connection pooling? I understand the best method is to get rid of datasets and use custom data objects. Any ideas?


Connection Pooling is based on the connection string so changing it dynamically for each SqlConnection you are creating will defeat its purpose.


If you use the dataadapters you can just say :

fAdapter.Connection = new SqlConnection("connectionstring");

Pooling is automatic (if same connectionstring is used).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜