SIGN UP MEMBER LOGIN:    
ARTICLE

How Do I Choose a Data Provider?

Posted by Mahesh Chand Articles | ADO.NET in C# December 17, 2009
In this article I will explain about How Do I Choose a Data Provider?
Reader Level:

This article has been excerpted from book "A Programmer's Guide to ADO.NET in C#".

As you've seen earlier there are many data providers available in ADO.NET. There may be cases when you can access a data source using more than one data provider. Now the question arises: which one is better? What are the selection criteria? The main criterion of selection is performance and multiple data source connectivity.

In brief, to work with SQL server 7 or later and MSDE databases, Sql data provider is the best choice. The Sql data provider bypasses many layers and directly connects to the internal layer of the infrastructure. Not only that but Sql data providers provide classes that help you to convert from native SQL server data typed to the .NET data types, and vice versa.

OleDb data providers are useful when you want to access OLEDB data sources such as MS-Access, XML, text, and other data sources. Because of the COM nature of the OLEDB API, it reduces many layers in comparison to ODBC data providers. This is also useful when you don't have an ODBC driver for a data source and have OLEDB provider.

The ODBC data providers utilize the existing way to work with data sources. ODBC is an older data access technology. Many applications still use ODBC to access data sources. ODBC data providers provide a way to access ODBC data source through ODBC drives and ODBC Admin. Database venders generally provide the ODBC drivers. Using ODBC you can access any data source for which you have an ODBC driver installed.

In general, ODBC data provider connectivity is faster than OLE-DB because of OLE DB's COM nature, which is very "chatty." Sql data provider is faster than ODBC to work with Sql server databases. But ODBC is useful when you need to write generic classes that can access multiple data source through ODBC for example, say you're writing an application that can work with multiple back-end servers including SQL server, Oracle, Access, and MySql. When you install these back- end servers, it also installs the ODBC driver for these databases. So you can write a generic application that can access these data source based on ODBC DSN. You can also pass the driver and data source information in the application itself, but the user has to create a DSN from ODBC, and the application can use that DSN as the connection string in the application for the ODBC data provider.

Adding Data Provider Namespace References

Data provider is defined in a separate namespace. The namespaces for the OleDb, Sql, and ODBC data providers are System.Data.OleDb, System.Data.Sqlclient, and Microsoft.Data.Odbc, respectively. Before using data adapter classes, you must add a reference of the correct namespace to your project. For example, add the following line for the Ole Db data provider:


using
System.Data.OleDb;

Add the following line for the Sql data provider:


using
System.Data.SqlClient;

And add the following line for the ODBC data provider:


using
Microsoft.Data.Odbc;

Conclusion

Hope this article would have helped you in understanding How Do I Choose a Data Provider? See my other articles on the website on ADO.NET.


adobook.jpg This essential guide to Microsoft's ADO.NET overviews C#, then leads you toward deeper understanding of ADO.NET.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor