共用方式為


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();

適用於

另請參閱