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 shows you "how to use DataAdapter to optimize ADO.NET connection pool", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use DataAdapter to optimize ADO.NET connection pool" this article.
The SQL Server, OLE DB, and .NET Framework data providers for ODBC implicitly buffer connections. You can control the behavior of ADO.NET connection pooling by specifying different property values in the connection string.
The Fill and Update methods of DataAdapter automatically open the connection specified for the relevant command properties when the connection is closed. If the Fill or Update method opens the connection, Fill or Update will close it when the operation is complete. For * performance, keep the connection to the database open only when needed. At the same time, reduce the number of times to open and close multi-operation connections. If only a single Fill or Update method call is performed, it is recommended that you allow the Fill or Update method to implicitly open and close the connection. If there are many calls to Fill and Update, it is recommended that you explicitly open the connection, call Fill and Update, and then explicitly close the connection. In addition, when a transaction is executed, the connection is explicitly opened before the transaction starts and closed after the transaction is committed. For example:
'Visual Basic Public Sub RunSqlTransaction (da As SqlDataAdapter, myConnection As SqlConnection, ds As DataSet) myConnection.Open () Dim myTrans As SqlTransaction = myConnection.BeginTransaction () myCommand.Transaction = myTrans Try da.Update (ds) myTrans.Commit () Console.WriteLine ("Update successful.") Catch e As Exception Try myTrans.Rollback () Catch ex As SqlException If Not myTrans.Connection Is Nothing Then Console.WriteLine ("An exception of type" & ex.GetType (). ToString () & "was encountered while attempting to roll back the transaction.") End If End Try Console.WriteLine ("An exception of type" & e.GetType (). ToString () & "was encountered." Console.WriteLine ("Update failed.") End Try myConnection.Close () End Sub / / C # public void RunSqlTransaction (SqlDataAdapter da, SqlConnection myConnection, DataSet ds) {myConnection.Open (); SqlTransaction myTrans = myConnection.BeginTransaction (); myCommand.Transaction = myTrans; try {da.Update (ds); myCommand.Transaction.Commit (); Console.WriteLine ("Update successful.");} catch (Exception e) {try {myTrans.Rollback () } catch (SqlException ex) {if (myTrans.Connection! = null) {Console.WriteLine ("An exception of type" + ex.GetType () + "was encountered while attempting to roll back the transaction.");}} Console.WriteLine (e.ToString ()); Console.WriteLine ("Update failed.");} myConnection.Close (); these are all the contents of the article "how to use DataAdapter to optimize ADO.NET connection pooling". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.