Udostępnij za pośrednictwem


ConnectionSettings.ThrowIfPropertyNotSet Method (String, String, Boolean)

Throws an exception if the specified connection property is null or, optionally, empty.

Namespace: Microsoft.SqlServer.Management.Common
Assembly: Microsoft.SqlServer.ConnectionInfo (in microsoft.sqlserver.connectioninfo.dll)

Syntax

'Deklaracja
Protected Function ThrowIfPropertyNotSet ( _
    propertyName As String, _
    str As String, _
    checkEmpty As Boolean _
) As String
protected string ThrowIfPropertyNotSet (
    string propertyName,
    string str,
    bool checkEmpty
)
protected:
String^ ThrowIfPropertyNotSet (
    String^ propertyName, 
    String^ str, 
    bool checkEmpty
)
protected String ThrowIfPropertyNotSet (
    String propertyName, 
    String str, 
    boolean checkEmpty
)
protected function ThrowIfPropertyNotSet (
    propertyName : String, 
    str : String, 
    checkEmpty : boolean
) : String

Parameters

  • propertyName
    A string that specifies the name of the connection property, such as "Login".
  • str
    A String object that contains the property value.
  • checkEmpty
    True if you want to check the property value for an empty string or null value; false if you want to check only for a null value.

Return Value

If the property is not set, this method throws a PropertyNotSetException. Otherwise, this method returns the str parameter value.

Remarks

If you want to throw the exception if the property value is an empty string, set the checkEmpty parameter to true.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server.