The Provider Factory in ADO.NET 2.0
(Page 1 of 4 )
The provider factory object in ADO.NET 2.0 lets you create commands for data that are independent of the database in which it is stored. If you want to learn more about this very useful item, keep reading.
Different database products have different providers. If the connection string and the provider can be disassociated, then the provider information can be stored in a central location such as the Machine.config file. This came into being with ADO.NET 2.0. Since there are many providers (MS SQL, Oracle, SQL Anywhere, and so on), they form a collection which can be interrogated at run time and modified at runtime. The provider factory object then provides support to create connections, commands, and data adapters that are independent of the underlying database. This tutorial looks at the abstract provider factory as described in ADO.NET 2.0.
What is the Provider Factory?
In order to get a basic understanding of the enhanced architecture of ADO.NET let us start a new Asp.NET web site project, Factory in VS 2005 using the installed template as shown in the next picture.

Since the Provider Factory is a generic model applicable to all data sources, it is found in the System.Data.Common namespace. After setting the reference to this by using the imports statement, the DbProviderFactories object's properties and methods can be seen in the object browser as shown in the next picture. This shows that you can access the DbProviderFactory using the GetFactory() methods. In the next section we will look at all the DbProviderFactories available on this machine.

Next: Data Providers on This Machine >>
More .NET Articles
More By Jayaram Krishnaswamy