Thoughts on OLE DB and .NET
You don't know. However, in the face of a real question "What is the software?" I have no suitable answer. Imagine such a scene: in a tourist souvenir shop, you are focusing on purchasing some things that are useless (mainly souvenirs) so that you will be happy to pick your friends and relatives to the airport. At this time, someone will often ask you: "Is the first time? Is the business trip or vacation?" So, if you are doing and software related things, not on vacation, then you have to face this reality . So, what is the software? Answering this question is very difficult, especially if you are leisurely, carry a back package postcard, koa picture and kangaroo toys, the yellow warning sign of the anti-crocodile is also printed. I am trying to make my thinking free and as simple as possible. First, the software is related to the computer. The software is also related to the evolution. Of course, the software is also related to data (especially data storage, and operation). After returning to the hotel, I am still thinking about the following questions - about the storage and use of data, I have observed what evolution in recent years? So I started thinking about OLE DB and its evolution in .NET. Software Emorisms From a historical perspective, ODBC has made a first serious attempt: it tries to create a way to create a unified application access to the database. Like other things in the software, the design purpose of ODBC is to meet certain needs. It has created a new stage in the evolutionary process of information technology, and there is a new phase. ODBC must provide a public (best abstract) API to access databases without considering the internal details of the database, language and table organizations. However, over time, people find that the design and constructing method of new data-driven applications, ODBC is increasingly unable to successfully meet the needs. The software also has its own evolution. ODBC adapted to changes in different names, different programming models and new features, survived, while maintaining its true mission. ODBC continues to provide (or less) the function of open database connections with the Name and function of OLE DB. The OLE DB is used as a programming interface to apply the theoretical concept of Microsoft General Data Access (UDA) policies to practice. UDA can access various types of data by a single programming interface based on COM, including relational, non-relational, and hierarchical data. OLE DB is designed as a component technology, which is characterized by a multi-layer model. On one side of the COM bridge is a server component for retaining data, and the other side is to understand how to connect and request data client components. The former is called OLE DB data providers; while the latter is called OLE DB users. Users and providers are COM objects and can communicate with each other through a set of COM interfaces. This COM-based communication can be summarized as an operation performed on an abstract object (such as DataSource, Session, Command, and RowSet). Therefore, this will happen when the user connects to DataSource, open session, issue Command, and return data ROWSET. This evolution of ODBC adds a function of UDA and OLE DB, just like a simple relationship table, bonding all corporate data together, whether they are relational, non-relational or hierarchical type. OLE DB models say data access, we have two basic choices. One is to use a general data access policy as in UDA. Another will tend to use a general data structure. It forcesses existing information from the current data store to a database server that can contain all data types.
Using OLE DB, you need to bond all of our information. Another way is to upgrade the client to new, more powerful, unique DBMS, and this DBMS can handle information in any format. Compared with ODBC, OLE DB has less dependence on data physical structures. In addition, it does not have to strictly based on SQL. The OLE DB command can be a SQL statement or something else. In general, they can be seen as a text string written by any grammar that can understand the target provider. Like ODBC, OLE DB is designed with C concepts to improve the performance of interlayer module data access as much as possible. Based on the same reason, OLE DB cannot be used directly in Visual Basic® or ASP. And countless distributed systems are used to generate components using Visual Basic. This is the main reason for Microsoft introduced an ActiveX® Data Object (ADO) library. The programming interface of the ADO is more abundant than the original OLE DB SDK. Although using ADO is fully feasible in C applications, the code hierarchy passed by the OLE DB call is less, and the data can be reached more directly than the corresponding ADO code. Although ADO is clearly generated on the OLE DB, call the original OLE DB interface and the call sent by the ADO runtime has different relative speeds. This fact has led to the difference between the language. Which one is better, it is worth recommending? Is OLE DB C high performance level or simple, more friendly ADO model in the Visual Basic component? In addition to providers and users, the OLE DB model also includes the third element --ole DB service. The service is a COM component that processes the "rows" that returns to the user. It works like hooks, oversight all communications between users and providers. ADO depends to the OLE DB service to add its extension, such as data, persistent, and disconnected records. Therefore, since people have begun to pay attention to constructing COM-based distributed applications, a variety of best examples of certain specific areas have been developed. In order to improve the scalability of the web application, people turn on the disconnect model using the data access. Simply put, data users and data providers are not always connected. Once the connection is established, the specified query can be issued, get the record and put it into the repository in the memory, and then disconnect from the data source. Then you process these records in offline, and reconnect or submit changes when you need it. This model is not available in all situations, but once it acts, you will find that it is very valuable in scalability and overall performance. Many systems have been converted (or re-conversion), and the ADO record set is deployed through the client game service to enable data disconnection. OLE DB is still a model dedicated to such interactions, so ADO is extended through an intermediate OLE DB service. Due to its inherent flexibility in which the structure is inherent, OLE DB can be successfully applied to disconnecting schemes, but this is certainly not the best working mode. Another small restriction of this implementation is: the program is more dependent on the ADO recordset, so that people suspect that it is not possible to always do everything well. How can this object becomes the fastest work tool in a variety of situations, whether it is a connection or disconnection, is there an XML, is it created or loaded from disk? In addition, considering that the functional packet of ADO is significantly different from the original OLE DB SDK, using OLE DB will result in significant inconsistencies. Therefore, ADO.NET becomes a next step in data access technology evolution.
However, from the name of the name, ADO.NET seems to be just ADO's successor. What is the OLE DB in .NET? The .NET hosted provider The eternal evolution law is now advanced by OLE DB technology to meet the requirements of new users. In .NET, the web application is first a disconnected application that uses newly designed special tools to manage data. The .NET framework allows the class to handle data. These classes - especially ADO.NET and XML namespace - available, read, and write. The ADO.NET and XML subsystem finally replaced ADO and OLE DB SDK. Now, you have a unique, language-centered approach to get and set data. The ADO.NET class is better than the data source is better than the ADO because it is explicitly designed to be centered on data, while the ADO is still using the database-centric design. Part of the .NET corresponding to the portion of the OLE DB data provider is called "hosting provider". Their roles are shown below. Figure 1: Hierarchical chart of managed provider can identify two interaction layers in OLE DB, i.e., the hosted user layer and the managed provider layer mentioned above. When processing data, the .NET application does not have to use a special class or component as the user module. If the .NET application uses only the DataSet or DataReader object in the unit frame, it will immediately become a "hosting" data user. To truly obtain data, use special classes from DataSetCommand and DBCommand. These classes represent links to the data source. You only need to learn how to deal with the export class for a given provider, without guiding the generic object to process a given provider. So the situation, SQLDataSetCommand will process the SQL Server database, and AdodatasetCommand will package all existing OLE DB providers. The managed provider will hide in such a DataSetCommand class. You will never be aware of their existence, or you don't need to know them. As long as you use classes and setting properties, this is a pleasant. In this case, the interactive module used by the managed provider layer in the above figure is not too different from the modules used in OLE DB or even earlier ODBC. The user command class is a specific component of the package data source. It understands the protocol used to read and write data lines in the source. It also returns the result in a format that can be treated well in a .NET class. For ease of understanding, let's review the commonality of OLE DB and .NET data retrieval.
OLE DB provider .NET hosted provider ID COM PROGID Package Returns the Special Command Provider for RowSet or Ado RecordSetDataset or DataReader class update method provider's special command provider's special command delivery Format Binary XML Table 1: Compare OLE DB and. The NET data provider target provider is identified by its COM PROGID located in OLE DB, and in .NET, these details are hidden in the accessor class. The OLE DB provider always returns a rowset - COM object primarily provides an IROWSET interface. If you access data via ADO, the row will be converted to a richer and more scriptical object, called a recordset. The .NET application only uses various classes with different functions. The DataReader class is a simple, fast, only moving cursor, working in connection, and provides access by recording. The connection must be explicitly disconnected after the end. Instead, the DataSet object is a disconnected set table in memory. It is an example of the fill of the DataSetCommand class. The content of the DataSet object is based on the XML stream from DataSetCommand from the data source. I will tell the contents of DataReader and DataSet in the later columns. The data arrives in the user in a binary format, and if the OLE DB is deployed, it will also pass the COM configuration. In .NET, the managed provider will return an XML stream. Both providers support query languages (usually SQL and all vendor-specific extensions). Update and interrogation data sources can be performed by this language. So what is the difference between the OLE DB data provider and the .NET data provider? Abstract, they use the same data access strategy. But the managed provider is simpler and professional. Two main reasons have led to the superiority of its performance. First, the managed provider does not use the COM interoperability bridge to acquire and set data. As a COM assembly, the OLE DB provider is not selected at this point. Second, managed providers typically acquire and set up rows faster using internal data source knowledge from the supplier. The OLE DB provider is also doing so, but when used inside .NET, the OLE DB provider must pay for its COM-based feature, and require additional code to convert data to a .NET unique class. The existing managed provider is like in Beta 1, the NET framework features a character with two hosted providers: one for SQL Server (7.0 or higher), one for all OLE DB providers data source. SQL Server managed providers are hidden after specific classes (such as SQL DataReader, SQL DatasetCommand, and SQLCommand). These classes directly access the low-level SQL Server file system. The following figure is a class diagram of the provider. This figure maps the previous general architecture to the SQL Server managed provider. Figure 2: The role of the SQL Server managed provider's class OLE DB hosted provider in .NET is the same as the role of the ODBC OLE DB provider in the Windows DNA system. Simply put, it reflects the backward compatibility, which reflects the fact that all .NET applications can face any existing data sources based on OLE DB. The class diagram of the OLE DB hosted provider is shown below. Figure 3: Class diagram of the OLE DB managed provider Please note that in Beta 2, the Adoxx class needs to be renamed OLEDBXXX. The OLE DB hosted provider will provide the .NET class to the caller, but use the specified OLE DB provider to get rows. The communication between the .NET application and the underlying OLE DB provider (COM object) occurs through the COM interoperability bridge.
In general, you can access the SQL Server 7.0 (and higher) tables through the above two providers. SQL Server's managed provider requests data directly from the DBMS file system, while the OLE DB managed provider relies on the service of the SQLOLDB OLE DB provider, resulting in an additional level of code. Now, if you face any data sources other than SQL Server, the OLE DB hosted provider is the only channel. With the same channel, you can also reach any ODBC data source. The OLE DB hosted provider is a thin package generated on a COM interoperable bridge that can be transferred to the local OLE DB provider. In addition to setting up and terminating calling, this module is also responsible for packaging returned rows to the DataSet or ADO DataReader object for subsequent .NET processing. On the .NET code layer, access the SQL Server table through a local managed provider or OLE DB provider is actually changing the prefix of the class involved. The following is the code for SQL Server: DIM STRCONN, STRCMD AS STRINGSTRCONN = "Database = Northwind; Server = localhost; UID = SA; PWD =;"
Strcmd = "SELECT * from Employees"
DIM OCMD As New SqldatasetCommand (Strcmd, StrConn)
Dim ODS AS New DataSet
Ocmd.FillDataSet (ODS, "EmployeesList")
The following is a code for the OLE DB provider (different in bold representation): DIM STRCONN, STRCMD AS STRING
StrConn = "provider = sqloledb;"
StrConn = "Database = northwind; server = localhost; uid = sa; pwd =;"
Strcmd = "SELECT * from Employees"
DIM OCMD AS New AdodatasetCommand (Strcmd, Strconn)
Dim ODS AS New DataSet
Ocmd.FillDataSet (ODS, "EmployeesList")
It can be seen that the difference is very small; only the connection string and the command class are different. And use a class or another, the difference is very large. OLE DB Existence The .NET managed provider represents the next development direction of data access technology evolution, but there is no documentation in Beta 1, there is no documentation, the SDK involves a specific managed provider of data source. Several basic issues about OLE DB and .NET are unlikely. They are waiting for Beta 2. Is it just an outdated code for all code developed by OLE DB? How will the company have put (and often invested every effort for writing providers for their own data)? Adhere to your beliefs --ole DB is not a desirable technology. Especially for functional, universal and independent. Net programming interface, it is still a basic specification. It is not specifically for .NET, but it has gained good support. That is to say, if you want to disclose custom data, you cannot ignore the appearance of .NET and managed providers. So what is the best interface of packaging data providers? How should you plan to publicize your data as soon as possible? For example, starting from 8 am in the next Monday? .NET uses open standards and widely based on XML. In this case, if you need to openly have all rights and text-based data, you only need to consider using XML (possibly a custom scheme) to be released. There are so many tools in .NET to work with XML data, the generation of packaging classes should have no problem. For more complex data storage, the OLE DB provider is still meaningful because your user group is larger, but may not only be limited to .NET. For .NET proprietary applications, managed providers can of course provide huge performance advantages, but I have a very cautious attitude towards this - especially to make a decision in such a short time! Don't forget that there is no SDK on the managed provider so far, although Microsoft has made this commitment. In short, this Monday morning I will start writing next to the next data provider will include a pair of OLE DB data providers and a .NET packaging class using XML. My primary choice will not be packaged with the OLE DB provider with the .NET class via COM Intero. I would rather use the same, have been adjusted source code. In this case, the hosted C is likely to facilitate the best language for "physical" code. The OLE DB ending allows us to use this as a prophecy, leaving the future from the future. I have to take the liberty that OLE DB will be like SGML (the predecessor of standard universal tag language, XML), and its final end will not be ideal. The SGML introduced as the Savior of the Data Exchange World has never become the actual standard, perhaps because it is too powerful and complicated for everyday use. The truth is that it is exciting principle that has been properly reduced and specialized, and generates XML before being accepted extensively. My prediction is that once .NET stabilizes its foundation, OLE DB will gradually lose its importance until it will eventually disappear. I can't determine how long this process will last, but I am sure this. The argument is in the following