SqlContext.IsAvailable Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Specifies whether the calling code is running within SQL Server, and if the context connection can be accessed.

Namespace:   Microsoft.SqlServer.Server
Assembly:  System.Data (in System.Data.dll)

public static bool IsAvailable { get; }

Property Value

Type: System.Boolean

True if the context connection is available and the other SqlContext members can be accessed.

If this property returns false, all the other SqlContext members throw an InvalidOperationException if used.

If this property returns false, any attempt to open a connection object that has "context connection=true" in the connection string fails.

This property is read-only.

When using ADO.NET for data-access, if a piece of code may run both inside SQL Server (using common language runtime integration) and outside SQL Server, this property can be used to check whether the context connection is available.

.NET Framework
Available since 2.0
Return to top