发布网友 发布时间:2022-04-23 04:08
共1个回答
热心网友 时间:2022-04-07 17:58
ADO.NET 具有几个专用对象以执行特定任务,用于代替记录集对象。表 1 描述了其中的三个专用对象:DataAdapter、DataReader 和 Dataset。
表一:DataAdapter The DataAdapter object provides a bridge between the database and a DataSet. The key advantage of DataAdapter is that it can work with any data source. The data source might be a database or it might be an XML document.
//DataAdapter提供了一个数据库与DataSet之间的桥梁。它最大的优点在于能工作于不同的数据源,这些数据源可以是数据库,也可以是 XML文件。
DataReader The DataReader object provides an efficient way to retrieve records on the server side. DataReader is a connected, read-only, and forward-only data-access mode. This object is useful for Web applications, which use DataReader to display records on Web pages.
//DataReader对象提供了从服务器端高效获取数据的途径,它是在只读和只进的连接模式下从数据源读取数据的,这个对象对通过网页展示数据记录的Web应用程序开发很有用。
DataSet The DataSet object provides disconnected copies of records from a database. The DataSet object stores records from a table (or multiple tables) in memory without holding a connection to the server. When in memory, DataSet is a binary object. When the DataSet is remoted, transferred, or serialized, it''s represented as a DiffGram—an XML format. Because XML is plaintext, records can be exchanged easily over the Web, bypassing firewall restrictions(*性). DataSet also contains various objects—such as constraints(压缩), relationships, and views—that let you manipulate(操作) tables on the client side instead of working through one Recordset in ADO.
//DataSet对象在断开数据库连接的情况下提供了一个数据库内容的拷贝,它把记录从表中取出,以二进制对象的形式存放在内存中。当Dataset被调用的时候,它表现为DiffGram--一种XML格式。