Condividi tramite


Metodo SqlConnectionFactory.CreateConnection

[Questa pagina è specifica della versione 6 di Entity Framework. La versione più recente è disponibile come pacchetto NuGet per "Entity Framework". Per ulteriori informazioni su Entity Framework, vedere la pagina msdn.com/data/ef.]

Crea una connessione per SQL Server basata sul nome di database o sulla stringa di connessione specificati. Se la stringa specificata contiene un carattere '=', viene trattata come una stringa di connessione completa; in caso contrario, viene trattata solo come un nome di database.

Spazio dei nomi:  System.Data.Entity.Infrastructure
Assembly:  EntityFramework (in EntityFramework.dll)

Sintassi

'Dichiarazione
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")> _
Public Function CreateConnection ( _
    nameOrConnectionString As String _
) As DbConnection
'Utilizzo
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

Parametri

  • nameOrConnectionString
    Tipo: System.String
    Nome di database o stringa di connessione.

Valore restituito

Tipo: System.Data.Common.DbConnection
Oggetto DbConnection inizializzato.

Implements

IDbConnectionFactory.CreateConnection(String)

Vedere anche

Riferimento

SqlConnectionFactory Classe

Spazio dei nomi System.Data.Entity.Infrastructure