DataSets
ADO.NET uses the DataSet to store disconnected data. This new structure is similar to an ADO recordset, but it has some important differences. For example, an ADO recordset looks like a single table, even if the data is from multiple tables. The final recordset is merely rows and columns. A DataSet, however, can store multiple tables in its cache. You can define the relationships between these tables, and then read from individual tables or join tables and retrieve data. A DataSet, in a sense, works like a miniature copy of the database, although it usually contains only a small subset of the data or the tables. A DataSet knows nothing about the underlying database. In fact, multiple underlying databases could make up the data in a DataSet. There is no reason why some of the data couldn’t be from SQL Server while other data comes from Oracle. Another object, the DataSet adapter, holds the information regarding the connection to the underlying database. The DataSet adapter has methods that allow you to retrieve and update data, but these methods actually rely on you to provide the proper SQL statements or stored procedure names. Datasets know all about XML. If you need to pass a DataSet’s data from one component to another, the data is passed using XML. If you want to write a DataSet to disk to be able to retrieve it later, it is stored in XML format. ADO.NET uses XML because it is a standard format, and any consumer that understands XML can use that XML stream, transforming it as desired into whatever format is necessary. Contrast this to an ADO recordset, and you can see the advantages. An ADO recordset uses a binary format that has no meaning on another platform. XML, however, is a textbased standard that can be consumed by any platform. Further, that fact that XML is text means that it is quite easy to transfer it over HTTP.
NOTE:
干粉压片机机械传动系统设计与分析 Actually, ADO has allowed you to persist a recordset as XML for a while. However, this is not the default format; instead, you must call the Save method and pass a parameter to specify the XML format. XML is the default in ADO.NET. Another advantage to using XML as the transport is that unlike ADO’s disconnected record sets, passing a DataSet to another component is as simple as transferring text. With a disconnected recordset, you had a binary file that had to be marshaled across process boundaries, which was an expensive proposition.
Working with the ADO.NET Objects
There are a number of new objects in ADO.NET that are different from what ADO developers have been using. Some of the names sound similar to the names of ADO objects, but be careful that you don’t assume certain capabilities that might not exist. You’ve already seen a discussion of the DataSet, but this is like starting an ADO discussion with the recordset: It’s where you do most of the work, but it’s the endgame as far as the coding goes. Therefore, with ADO.NET, you need to understand how to make the database connection, and how to execute the statements that end up filling in the DataSet.
Connections: oleDbConnection and SQLConnection
The oleDbConnection object uses OLE DB to connect to a data source. ADO.NET also includes a new type of connection: SQLConnection. This works like the oleDbConnection object, but it does not use OLE DB. Instead, SQLConnection uses a native driver to connect to SQL Server and offers better performance than the OLEDB provider. Because some people reading this book might not have access to SQLServer, I will continue to use oleDbConnection.。Connecting to a data source is straightforward: Define the connection string, create the connection object, and open the connection.
上一页 [1] [2] [3] [4] [5] 下一页
VB.NET的数据库访问英文文献和翻译 第2页下载如图片无法显示或论文不完整,请联系qq752018766