Variable.Name Property

Definition

获取或设置变量的名称。Gets or sets the name of the variable.

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "NameDesc")]
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

Property Value

String

一个包含变量名称的字符串。A String that contains the name of the variable.

Implements

Attributes

Examples

下面的示例创建一个包,添加一个 ForEachLoop ,然后将一个变量添加到 Variables 的集合中 ForEachLoopThe following example creates a package, adds a ForEachLoop, and adds a variable to the Variables collection of the ForEachLoop. 然后,它将检索并设置变量的属性,并将其显示为供查看,包括 NameIt then retrieves and sets properties on the variable and displays them for viewing, including the Name.

static void Main(string[] args)  
        {  
            Package p = new Package();  
            // Add a sequence to the package executables collection  
            Sequence seq = (Sequence)p.Executables.Add("STOCK:SEQUENCE");  
            // Add a ForEachLoop to the Sequence  
            ForEachLoop feLoop = (ForEachLoop)seq.Executables.Add("STOCK:FOREACHLOOP");  
  
            // Add a variable, v, to the variable collection  
           // of the ForEach loop.  
            Variable v = feLoop.Variables.Add("v", false, "global", 100);  
  
//  Get and set different variable properties  
  
            // Creation Name (read-only)  
            String createName = v.CreationName;  
  
            // Description (read/write)  
            v.Description = "my new v Description";  
            String vDesc = v.Description;  
  
            // ID (read-only)  
            String vID = v.ID;  
  
            // Name (read/write)  
            String oldName = v.Name;  
            v.Name = "my_new_V_name";  
            String newName = v.Name;  
  
            // Namespace (read/write)  
            String oldNamespace = v.Namespace;  
            v.Namespace = "my_new_v_Namespace";  
            String newNamespace = v.Namespace;  
  
            // Properties (read-only)  
            int pmCount = v.Properties.Count;  
  
            // Qualified Name (read-only)  
            String QName = v.QualifiedName;  
  
            // RaiseChangedEvent (read/write)  
            Boolean oldraiseChEvt = v.RaiseChangedEvent;  
            v.RaiseChangedEvent = true;  
            Boolean raiseChangedEvent = v.RaiseChangedEvent;  
  
            // Read-only (read/write)  
            Boolean vReadOnly = v.ReadOnly;  
            v.ReadOnly = true;  
            Boolean newVReadOnly = v.ReadOnly;  
  
            // System Variable (read-only)  
            Boolean sysVar = v.SystemVariable;  
  
            // Type (read-only)  
            TypeCode type = v.DataType;  
  
            // Value (read/write)  
            Object vValue = v.Value;  
  
            Console.WriteLine("The variable properties are: ");  
            Console.WriteLine("Creation Name   = {0}", createName);  
            Console.WriteLine("Description        = {0}", vDesc);  
            Console.WriteLine("ID                     = {0}", vID);  
            Console.WriteLine("Old name, new name = {0}, {1}", oldName, newName);  
            Console.WriteLine("Old namespace, new namespace = {0}, {1}", oldNamespace, newNamespace);  
            Console.WriteLine("Properties count   = {0}", pmCount);  
            Console.WriteLine("Qualified Name     = {0}", QName);  
            Console.WriteLine("old RaiseEvent, new RaiseEvent = {0}, {1}", oldraiseChEvt, raiseChangedEvent);  
            Console.WriteLine("old read-only, new read-only = {0}, {1}", vReadOnly, newVReadOnly);  
            Console.WriteLine("System Variable    = {0}", sysVar);  
            Console.WriteLine("Type               = {0}", type);  
        }  
Shared Sub Main(ByVal args() As String)   
    Dim p As New Package()  
    ' Add a sequence to the package executables collection  
    Dim seq As Sequence = CType(p.Executables.Add("STOCK:SEQUENCE"), Sequence)  
    ' Add a ForEachLoop to the Sequence  
    Dim feLoop As ForEachLoop = CType(seq.Executables.Add("STOCK:FOREACHLOOP"), ForEachLoop)  
  
    ' Add a variable, v, to the variable collection  
    ' of the ForEach loop.  
    Dim v As Variable = feLoop.Variables.Add("v", False, "global", 100)  
  
    '  Get and set different variable properties  
    ' Creation Name (read-only)  
    Dim createName As String = v.CreationName  
  
    ' Description (read/write)  
    v.Description = "my new v Description"  
    Dim vDesc As String = v.Description  
  
    ' ID (read-only)  
    Dim vID As String = v.ID  
  
    ' Name (read/write)  
    Dim oldName As String = v.Name  
    v.Name = "my_new_V_name"  
    Dim newName As String = v.Name  
  
    ' Namespace (read/write)  
    Dim oldNamespace As String = v.Namespace  
    v.Namespace = "my_new_v_Namespace"  
    Dim newNamespace As String = v.Namespace  
  
    ' Properties (read-only)  
    Dim pmCount As Integer = v.Properties.Count  
  
    ' Qualified Name (read-only)  
    Dim QName As String = v.QualifiedName  
  
    ' RaiseChangedEvent (read/write)  
    Dim oldraiseChEvt As [Boolean] = v.RaiseChangedEvent  
    v.RaiseChangedEvent = True  
    Dim raiseChangedEvent As [Boolean] = v.RaiseChangedEvent  
  
    ' Read-only (read/write)  
    Dim vReadOnly As [Boolean] = v.ReadOnly  
    v.ReadOnly = True  
    Dim newVReadOnly As [Boolean] = v.ReadOnly  
  
    ' System Variable (read-only)  
    Dim sysVar As [Boolean] = v.SystemVariable  
  
    ' Type (read-only)  
    Dim type As TypeCode = v.DataType  
  
    ' Value (read/write)  
    Dim vValue As [Object] = v.Value  
  
    Console.WriteLine("The variable properties are: ")  
    Console.WriteLine("Creation Name   = {0}", createName)  
    Console.WriteLine("Description        = {0}", vDesc)  
    Console.WriteLine("ID                     = {0}", vID)  
    Console.WriteLine("Old name, new name = {0}, {1}", oldName, newName)  
    Console.WriteLine("Old namespace, new namespace = {0}, {1}", oldNamespace, newNamespace)  
    Console.WriteLine("Properties count   = {0}", pmCount)  
    Console.WriteLine("Qualified Name     = {0}", QName)  
    Console.WriteLine("old RaiseEvent, new RaiseEvent = {0}, {1}", oldraiseChEvt, raiseChangedEvent)  
    Console.WriteLine("old read-only, new read-only = {0}, {1}", vReadOnly, newVReadOnly)  
    Console.WriteLine("System Variable    = {0}", sysVar)  
    Console.WriteLine("Type               = {0}", type)  
End Sub   

示例输出:Sample Output:

变量属性为:The variable properties are:

创建名称 =Creation Name =

Description = 我的新的 v 描述Description = my new v Description

ID = {622CF328-55D7-4E81-9385-9C1F8450511E}ID = {622CF328-55D7-4E81-9385-9C1F8450511E}

旧名称、新名称 = v、my_new_V_nameOld name, new name = v, my_new_V_name

旧命名空间,新命名空间 = 全局,my_new_v_NamespaceOld namespace, new namespace = global, my_new_v_Namespace

属性计数 = 12Properties count = 12

限定名 = my_new_v_Namespace:: my_new_V_nameQualified Name = my_new_v_Namespace::my_new_V_name

旧 RaiseEvent,new RaiseEvent = False,Trueold RaiseEvent, new RaiseEvent = False, True

旧只读,新的只读 = False,Trueold read-only, new read-only = False, True

系统变量 = FalseSystem Variable = False

类型 = Int32Type = Int32

Applies to