次の方法で共有


SqlConnectionFactory.CreateConnection メソッド

[このページは、Entity Framework 6 に関するページです。最新バージョンは、'Entity Framework' NuGet パッケージとして入手できます。Entity Framework の詳細については、msdn.com/data/ef を参照してください。]

指定されているデータベース名または接続文字列に基づいて SQL Server の接続を作成します。 文字列に "=" 文字が含まれている場合、その文字列は完全な接続文字列として扱われます。そうでなければ、データベースの名前としてしか扱われません。

名前空間:  System.Data.Entity.Infrastructure
アセンブリ:  EntityFramework (EntityFramework.dll 内)

構文

'宣言
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")> _
Public Function CreateConnection ( _
    nameOrConnectionString As String _
) As DbConnection
'使用
Dim instance As SqlConnectionFactory 
Dim nameOrConnectionString As String 
Dim returnValue As DbConnection 

returnValue = instance.CreateConnection(nameOrConnectionString)
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public DbConnection CreateConnection(
    string nameOrConnectionString
)
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1031:DoNotCatchGeneralExceptionTypes")]
public:
virtual DbConnection^ CreateConnection(
    String^ nameOrConnectionString
) sealed
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")>]
abstract CreateConnection : 
        nameOrConnectionString:string -> DbConnection 
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")>]
override CreateConnection : 
        nameOrConnectionString:string -> DbConnection
public final function CreateConnection(
    nameOrConnectionString : String
) : DbConnection

パラメーター

  • nameOrConnectionString
    型 : System.String
    データベース名または接続文字列。

戻り値

型 : System.Data.Common.DbConnection
初期化された DbConnection。

Implements

IDbConnectionFactory.CreateConnection(String)

参照

参照

SqlConnectionFactory クラス

System.Data.Entity.Infrastructure 名前空間