8.10. Write Database-Independent Code
Problem
You need to write code that can be configured to work against any relational database supported by an ADO.NET data provider.
Solution
Program to the ADO.NET data provider base classes that inherit the main interfaces, such as IDbConnection, in the System.Data namespace. Unlike the concrete implementations, such as SqlConnection, the base classes do not rely on features and data types that are unique to specific database implementations. Use factory classes and methods to instantiate the data provider objects you need to use.
How It Works
Using a specific data provider implementation (the SQL Server data provider, for example) simplifies your code and may be appropriate if you need to support only ...
Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.