Comparison of two methods for SQLServer connection in DOTNET development

zhaozj2021-02-16  61

In .NET's way about SQL Server, there are two ways to open the connection, one is under system.data.sqlclient namespace, I believe that many people are programmed with this method, and there is also in Microsoft.ApplicationBlocks .DATA.SQLHELPER Namespace, method is roughly the same, why have two different spaces provide similar features?

Microsoft attached two namespaces with System and Microsoft when launched .NET system, Microsoft namespaces are the powerful supplements of System namespace, which is based on the topics currently discussed, if they program them in system.data.sqlclient, will You need to use SQLCommand and SqlDataAdapter, you need to manage the database's opening and closing, for example

Cn.open (); // Open the database connection SqlDataReader DR = cmd.executeReader (Commandbehavior.CloseConnection); // Close the connection DR.Close (); // closes the dataset (also close the database connection) )

However, in Microsoft.ApplicationBlocks.Data.sqlhelper namespace, no tube, the same operation

SqlDataReader Dr = SQLHELPER.EXECUTEREADER (CN, CommandType.Text, QuerySQL);

Two-phase comparison, the next one is better not?

Since the Microsoft's system is programmed, the best choice is of course the maximum use of Microsoft, Microsoft namespace under the .NET system can be seen as a secondary development product of the basic function provided by Microsoft. It further optimizes the function. It is naturally not limited to the development of the database. It will take time to study more. Oh, it is rare. This product is still open source, and interesters can go to MSDN to download, now 2.0. .

I hope that there is a deep insight to teach me.

转载请注明原文地址:https://www.9cbs.com/read-17986.html

New Post(0)