ADO.net Connection Pooling -
In the code below, the provider object is only an example of a DbConnection. Each reader will reference the same connection example. According to the Microsoft documentation, the second reader will get a second connection from the connection pool. It works correctly.
(idataReader = Provider.GetReader (sqlStatement1) as using var reader1) {while (reader1.Read ()) {(idreader = provider using var reader2.)) {While reader2.Read ()} {// stuff with the two statements}}}}
By the time I am using the connection will be open however the provider object I do not want to waste the connection in connection pool. The provider will call. DB Connection Attempt to return both connections in the closed () pool? If so, how can I return the second connection to the connection pool?
After testing various connection providers, I have received my answer.
The OLEB Provider maintains its connection pool separately from the SQL client provider. Typically, the SqlClient provider should create a new SqlConnection object every time you want to connect to the database. Connection should be closed or disposed off. It releases the underlying connection in the pool.
Although the Olead Provider handles differently instead of starting a new connection every time, the same connection should be used in the object and disposed at the end of the application. If the SqlClient connection is used the same, and the error "unspecified error" is inserted, each OleDbCommand can be assigned the same OleDbConnection example. If it is already being used, the underlying provider will provide a new connection for it. This will generate an exception by doing it with SQL client providers.
My original connection string was: data source = .... mdb; Provider = Microsoft.Jet.OLEDB.4.0; It failed after 128 connections ... After researching connection pooling (not error) with a very friendly "unspecified error", this parameter must be added to turn on connection pooling.
With the onset of it, the connections used to behave as expected and there was no limit.
Comments
Post a Comment