In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the important features of ADO.NET". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the important features of ADO.NET"?
Microsoft's instructions for calling ADO.NET and MSDN sites all recommend that you use ADO.NET. To create Connection in this way, calling ADO.NET will automatically execute the Connection.dispose () method, so you can ensure that Connetion is closed in time.
So is it really so important to call .dispose () in time, calling ADO.NET if an object exceeds the living space, isn't it automatically cleaned up by GC (garbage collector) in .net?
The problem is actually caused by GC, the GC used in. Net, who is not as diligent in his work as we are. When calling ADO.NET, he will start cleaning (cleaning up unused objects) only when the external environment is extremely harsh (when there is not enough content to allocate). So even if Connection is beyond the lifetime of a variable, it may not have been killed by GC.
The call ADO.NET is still not returned to Connection Pool, so this causes the next connection to re-open a new connection by calling Connection without Available in ADO.NET, wasting extra performance for no reason. So ADO.net team repeatedly stressed the need to close the current connection in a timely manner. One way to * is to use using {} block system will automatically call the connection.dispose method when exiting {}, and dispose will automatically execute the close method to release the current connection.
In fact, the Connection.dispose method is to call the close method once, so the two methods are equivalent. That is, if you execute the connection.close () method in time, there is no need to wrap the connection in a using () {}.
If the use of calling ADO.NET is necessary, what if the program structure prevents me from wrapping my Connection with using () {}, for example, my Connection is returned by the same help class?
This is a common problem. In such an environment, we can't wrap the entire connection in one connection. There are two ways to solve this problem. One is to modify your code structure. Pass in a ConnectionString to return the call ADO.NET. Another way is to double-check your code to see if Connection is closed in time.
Because the effect of Close is the same as dispose. But if we don't use using () {}, the task of shutting down Connection in time is in our own hands, instead of being guarded by. Net framework.
Thank you for your reading, the above is the content of "what are the important features of ADO.NET". After the study of this article, I believe you have a deeper understanding of the important characteristics of ADO.NET, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.