共用方式為


VariableDispenser 類別

Accesses the Variables collection during package execution. This class cannot be inherited.

繼承階層

System. . :: . .Object
  Microsoft.SqlServer.Dts.Runtime. . :: . .DtsObject
    Microsoft.SqlServer.Dts.Runtime..::..VariableDispenser

命名空間:  Microsoft.SqlServer.Dts.Runtime
組件:  Microsoft.SqlServer.ManagedDTS (在 Microsoft.SqlServer.ManagedDTS.dll 中)

語法

'宣告
Public NotInheritable Class VariableDispenser _
    Inherits DtsObject
'用途
Dim instance As VariableDispenser
public sealed class VariableDispenser : DtsObject
public ref class VariableDispenser sealed : public DtsObject
[<SealedAttribute>]
type VariableDispenser =  
    class
        inherit DtsObject
    end
public final class VariableDispenser extends DtsObject

VariableDispenser 型別公開下列成員。

方法

  名稱 說明
公用方法 Contains Specifies whether an item can be retrieved from the VariableDispenser collection by using indexing without throwing an exception.
公用方法 Equals Determines whether two object instances are equal. (繼承自 DtsObject。)
受保護的方法 Finalize (繼承自 Object。)
公用方法 GetHashCode Returns the hash code for this instance. (繼承自 DtsObject。)
公用方法 GetQualifiedName Returns the qualified name of the variable.
公用方法 GetType (繼承自 Object。)
公用方法 GetVariables Locks the variables that are in the read-only list and the read/write list.
公用方法 LockForRead Adds the variable to the list of variables to be locked for read-only access.
公用方法 LockForWrite Adds the variable to the list of variables to be locked for read/write access.
公用方法 LockOneForRead Puts the variable in a list, and then locks it for read-only access.
公用方法 LockOneForWrite Puts the variable in a list, and then locks it for read/write access.
受保護的方法 MemberwiseClone (繼承自 Object。)
公用方法 Reset Clears both the read-only list and read/write list when the call to GetVariables fails.
公用方法 ToString (繼承自 Object。)

上層

備註

There are two scenarios for using the variable dispenser.

  1. You want just one variable. In this scenario, call LockOneForRead or LockOneForWrite, and a collection with one element is returned.

  2. You want several variables. In this scenario, call LockForRead and LockForWrite several times, one for each variable. This builds up two lists, one list that contains variables for reading and one list that contains variables for writing. Next, call GetVariables, which gives you a collection that contains all of the locked variables. If GetVariables succeeds, the two lists, which are the lists of variable names, not actual locks, are cleared.

To explicitly release the locks, call Unlock on the collection. This method unlocks the variables themselves. If GetVariables fails, the lists remain unchanged, and you can call GetVariables again. If you still do not succeed in obtaining the variables, call Reset to clear the lists and bring the variable dispenser back to its initial state.

The Variables collection contains a Locked property that indicates whether a variable dispenser collection of variables is locked (true) or unlocked (false). The reason to review this property is that some tasks explicitly release locks to the variables they are using, and calling Unlock twice throws an error. Therefore, you should use this property to determine whether the dispensed collection is locked before calling Unlock.

重要事項重要事項

The VariableDispenser is used with the Runtime classes. If you are using data flow components (Microsoft.SqlServer.Dts.Pipeline), then you may be required to use the IDTSVariableDispenser100 instead. To know which variable dispenser to use, see the documentation for the object you are acquiring variables on, and verify the return object of the method.

執行緒安全性

這個型別的任何公用 static (在 Visual Basic 中為 Shared) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。