简体   繁体   中英

Extensive use of SqlDataSource and too many 3306 time wait connections

Is it possible to exist the connection between the extensive use of asp:SqlDataSource and a lot of 3306 ports in time wait status?

Is it true that the asp:sqldatasource closes the connection automatically? if does not, how to close the connection made by a slqdatasource?

Thanks in advance, Firmino

Try <asp:SqlDataSource DataSourceMode="DataSet" /> .

From 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 requires open connection to operate - it returns data directly from DB. In constrast DataSet loads data from DB to memory so connection are opened only for actual read / update / insert / delete and can be closed (=returned to pool) afterwards.

Source: SqlDataSource.DataSourceMode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM