System.Data.Common 命名空间提供用于创建与特定数据源一起使用的 DbProviderFactory 实例的类。The System.Data.Common namespace provides classes for creating DbProviderFactory instances to work with specific data sources. 当创建 DbProviderFactory 实例并向其传递有关数据提供程序的信息时,DbProviderFactory 可以根据为其提供的信息确定要返回的正确的强类型连接对象。When you create a DbProviderFactory instance and pass it information about the data provider, the DbProviderFactory can determine the correct, strongly typed connection object to return based on the information it has been provided.

从 .NET Framework 4 开始,machine.config 文件中不再列出诸如 System.Data.OdbcSystem.Data.OleDbSystem.Data.SqlClientSystem.Data.OracleClient 等数据提供程序,但会继续列出自定义提供程序。Beginning in the .NET Framework version 4, data providers such as System.Data.Odbc, System.Data.OleDb, System.Data.SqlClient, and System.Data.OracleClient are no longer listed in machine.config file, but custom providers will continue to be listed there.

本节内容In This Section

工厂模型概述Factory Model Overview
提供工厂设计样式和编程接口概述。Provides an overview of the factory design pattern and programming interface.

获取 DbProviderFactoryObtaining a DbProviderFactory
演示如何列出安装的数据提供程序以及如何从 DbConnection 创建 DbProviderFactoryDemonstrates how to list the installed data providers and create a DbConnection from a DbProviderFactory.

DbConnection、DbCommand 和 DbExceptionDbConnection, DbCommand and DbException
演示如何创建 DbCommandDbDataReader,以及如何使用 DbException 处理数据错误。Demonstrates how to create a DbCommand and DbDataReader, and how to handle data errors using DbException.

使用 DbDataAdapter 修改数据Modifying Data with a DbDataAdapter
演示如何使用 DbCommandBuilderDbDataAdapter 检索并修改数据。Demonstrates how to use a DbCommandBuilder with a DbDataAdapter to retrieve and modify data.

请参阅See also