Add 方法

Adds a Variable object to the Variables collection.

命名空间:  Microsoft.SqlServer.Dts.Runtime
程序集:  Microsoft.SqlServer.ManagedDTS(在 Microsoft.SqlServer.ManagedDTS.dll 中)

语法

声明
Public Function Add ( _
    name As String, _
    readOnly As Boolean, _
    nameSpace As String, _
    val As Object _
) As Variable
用法
Dim instance As Variables
Dim name As String
Dim readOnly As Boolean
Dim nameSpace As String
Dim val As Object
Dim returnValue As Variable

returnValue = instance.Add(name, readOnly, _
    nameSpace, val)
public Variable Add(
    string name,
    bool readOnly,
    string nameSpace,
    Object val
)
public:
Variable^ Add(
    String^ name, 
    bool readOnly, 
    String^ nameSpace, 
    Object^ val
)
member Add : 
        name:string * 
        readOnly:bool * 
        nameSpace:string * 
        val:Object -> Variable 
public function Add(
    name : String, 
    readOnly : boolean, 
    nameSpace : String, 
    val : Object
) : Variable

参数

  • name
    类型:System. . :: . .String
    The name of the package, task, or container variable to add to the collection.
  • readOnly
    类型:System. . :: . .Boolean
    A Boolean that indicates whether the variable is read-only or whether the variable can be modified.
  • nameSpace
    类型:System. . :: . .String
    The namespace for the variable. Default value is the User variable namespace. You can also create a namespace to identify variables you create that are used in a certain part of a package. You cannot add variables to the System variable namespace.

返回值

类型:Microsoft.SqlServer.Dts.Runtime. . :: . .Variable
The newly created variable that was added to the Variables collection.

注释

For more information, see 在包中使用变量.

示例

The following example creates a package, and adds a variable, myVar, to its variable collection.

static void Main(string[] args)
        {
            Package p = new Package();
            //Add a variable, myvar, to the package variables
            // collection. The variable has a value of 5, in the myNamespace
            // namespace.
            Variable var = p.Variables.Add("myVar", false, "myNamespace", 5);
            //
            // Enter the rest of your code here.
            //
        }
Shared  Sub Main(ByVal args() As String)
            Dim p As Package =  New Package() 
            'Add a variable, myvar, to the package variables
            ' collection. The variable has a value of 5, in the myNamespace
            ' namespace.
            Dim var As Variable =  p.Variables.Add("myVar",False,"myNamespace",5) 
            '
            ' Enter the rest of your code here.
            '
End Sub