gpt4 book ai didi

c# - 大量使用 SqlDataSource 和太多 3306 时间等待连接

转载 作者:可可西里 更新时间:2023-11-01 02:54:01 25 4
gpt4 key购买 nike

是否大量使用asp:SqlDataSource与大量3306端口处于等待状态可能存在联系?

asp:sqldatasource 自动关闭连接是真的吗?如果没有,如何关闭 slqdatasource 建立的连接?

提前致谢,菲尔米诺

最佳答案

尝试 <asp:SqlDataSource DataSourceMode="DataSet" /> .

来自 MSDN:

The data retrieval mode identifies how a SqlDataSource control retrieves data from the underlying database. When the DataSourceMode property is set to the DataSet value, data is loaded into a DataSet object and stored in memory on the server. This enables scenarios where user interface controls, such as GridView, offer sorting, filtering, and paging capabilities. When the DataSourceMode property is set to the DataReader value, data is retrieved by a IDataReader object, which is a forward-only, read-only cursor. The specific type of the IDataReader object depends on the NET data provider that the SqlDataSource uses, which is identified by the ProviderName property. By default, the SqlDataSource control uses the provider for Microsoft SQL Server, the System.Data.SqlClient, and the data reader is a SqlDataReader object.

DataReader需要打开连接才能运行 - 它直接从数据库返回数据。相比之下DataSet将数据从 DB 加载到内存,因此连接仅在实际读取/更新/插入/删除时打开,之后可以关闭(=返回池)。

来源:SqlDataSource.DataSourceMode

关于c# - 大量使用 SqlDataSource 和太多 3306 时间等待连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37094852/

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