Share via


SqlContext.IsAvailable Property

Definition

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

public:
 static property bool IsAvailable { bool get(); };
public static bool IsAvailable { get; }
static member IsAvailable : bool
Public Shared ReadOnly Property IsAvailable As Boolean

Property Value

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

Remarks

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.

Applies to