SqlDataReader and SqlDataAdapter

xiaoxiao2021-03-06  41

SqlDataReader is efficient, weak, read-only access to SqlDataAdapter, requires a big better resources.

SqlDataReader can only be read in a state where it is kept connected to the database. . .

SqlDataAdapter is mostly reading a table at once, then populates to the DataSet, and then disconnects the database.

The difference between the two is mainly the difference between online and offline. . . . . One: SqlDataReader Rd; rd = cmd.executeReader ();

It's more efficient, if you just display the data, of course you have to use this

Two: SqlDataAdapter Adapter = New SqlDataAdapter (CMD); there are two categories in ADO.NET, which is DataSet, etc., you can take the data out, then disconnect, save server resources when you have done locally. After the changes, the job that updates this data and updating the data is made by SqlDataAdapter, he is "extended wire" - this metaphor is as if it comes from "ADO.NET technology insider" sqlDataReader // based on connection, Read-only access is suitable for smaller sqldataadapter // Based on non-connection, it is possible to modify it, and finally returns the modification result to the database. It is also required that SQLDATAREADER is like a linked list. It can only read data SqlDataAdapter. It is like they are very powerful 1. SqldataReader returns a data reader, only one class, can be read, operate Not flexible, usually used in just reading. 2. SqlDataAdapter returns a dataset or table, which can operate any data.

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

New Post(0)