Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

ADO.NET Managed Providers


COM Objects from ASP.NET Pages

A key architectural element in the ADO.NET infrastructure is the managed provider, which can be considered the .NET counterpart of the OLE DB provider. A managed data provider enables you to connect to a data source and retrieve and modify data. Compared to the OLE DB provider, a .NET managed provider has a simplified data-access architecture made of a smaller set of interfaces and based on .NET Framework data types.

A COM-based OLE DB provider is a monolithic component; in contrast, a managed provider is made of a suite of classes, each of which represents a particular step in the connection model that a data-aware application implements. A managed provider comprises classes for connecting to a particular data source, managing transactions, executing commands, and accessing result sets. For each of these steps, the managed provider supplies a particular class with its own set of properties, methods, and events. The union of these classes form the logical entity known as the managed provider for that data source.

In the .NET Framework, each managed provider is characterized by a prefix that qualifies the various classes of the same type. For example, the class that manages connections to SQL Server is called SqlConnection, while the class that opens a connection to an Oracle database is OracleConnection. In the former case, the prefix is Sql; in the latter, it is Oracle.

The classes in the managed provider interact with the specific data source and return data to the application using the data types defined in the .NET Framework. Objects contained within a managed provider include Connection, Transaction, Command, Parameter, Data adapter, and Data reader.

The Connection object creates a connection with the specified data source, be it SQL Server, Oracle, or any data source for which you can indicate either an OLE DB provider or an ODBC driver. Strictly dependent on the connection is the Transaction object. It represents a transaction to be made in the source database server. While connection pooling is sometimes implemented within the ADO.NET infrastructure, any transaction related features are delegated to the underlying database server.

The Command object represents a command-typically, a SQL statement or a stored procedure name-that hits the data store. The command may be further characterized by using parameters. A Parameter object simply represents a parameter that you can pass to the Command object. The Data adapter is a particular type of a database command. It executes on the specified database server and returns a disconnected set of records. Internally, a Data adapter makes use of a Data reader, which emulates the behavior of a read-only, forward-only cursor created on the database. You normally use a Data adapter when you need to cache the result set for further processing. You use a Data reader when you are going to consume the records immediately without storing them.

You should note that, as of .NET Framework 1.1, ADO.NET managed providers don't support server cursors. If your application can't be reworked to do without server cursors, the best way of proceeding is just sticking to the ADO library, which is easily callable from within a .NET application.


Dino Esposito is Wintellect's ADO.NET and XML expert, and a trainer and consultant based in Rome, Italy. Dino is a contributing editor to Windows Developer Magazine and MSDN Magazine, and the author of several books for Microsoft Press including Building Web Solutions with ASP.NET and ADO.NET and Applied XML Programming for .NET. Contact Dino at [email protected].


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.