.Net是否可以像PHP一样进行巧妙的连接管理? [英] Does .Net do clever connection management like PHP?

查看:67
本文介绍了.Net是否可以像PHP一样进行巧妙的连接管理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET页面加载期间,我正在打开和关闭页面中包含的多个控件内的多个System.Data.SqlClient.SqlConnections.我认为,最好创建一个连接池",并在打开连接时检查连接字符串是否与池中打开的连接匹配,然后返回该连接.我原本希望页面加载时间有所不同,但是我没有看到任何变化.我知道,对于PHP,如果您尝试使用该页面请求中已使用的连接字符串来打开新连接,则它将不会尝试打开新连接,而是返回现有的打开连接..NET是真的吗?

解决方案

连接池是ADO.NET的一项基本功能.

阅读此 MSDN文章或其他一些可用资源在网络上,例如博客文章

During an ASP.NET page load I'm opening and closing multiple System.Data.SqlClient.SqlConnections inside multiple controls contained in the page. I thought it would be a good idea instead to create a "pool" of connections and when opening a connection check to see if the connection string matches that of an open connection in the pool, and return that connection. I was expecting to see a difference in the page load times, but I haven't seen any change. I know that with PHP if you attempt to open a new connection with a connection string that has already been used in that page request it won't attempt to open a new connection and will return the existing open connection instead. Is this true with .NET?

解决方案

Connection pooling is an essential feature of ADO.NET.

Read this MSDN article or some of the other resources available on the net, like this blog post

这篇关于.Net是否可以像PHP一样进行巧妙的连接管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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