SqlClientFactory.CreateConnection 方法

定义

返回强类型的 DbConnection 实例。

public:
 override System::Data::Common::DbConnection ^ CreateConnection();
public override System.Data.Common.DbConnection CreateConnection ();
override this.CreateConnection : unit -> System.Data.Common.DbConnection
Public Overrides Function CreateConnection () As DbConnection

返回

DbConnection 的新强类型实例。

示例

以下代码片段返回强类型 DbConnection 实例:

Dim newFactory As SqlClientFactory = SqlClientFactory.Instance
Dim cmd As DbConnection = newFactory.CreateConnection()
SqlClientFactory newFactory = SqlClientFactory.Instance;
DbConnection cmd = newFactory.CreateConnection();

适用于

另请参阅