Variables.Add(String, Boolean, String, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
Microsoft::SqlServer::Dts::Runtime::Variable ^ Add(System::String ^ name, bool readOnly, System::String ^ nameSpace, System::Object ^ val);
public Microsoft.SqlServer.Dts.Runtime.Variable Add (string name, bool readOnly, string nameSpace, object val);
member this.Add : string * bool * string * obj -> Microsoft.SqlServer.Dts.Runtime.Variable
Public Function Add (name As String, readOnly As Boolean, nameSpace As String, val As Object) As Variable
Parameters
- name
- String
The name of the package, task, or container variable to add to the collection.
- readOnly
- Boolean
A Boolean that indicates whether the variable is read-only or whether the variable can be modified.
- nameSpace
- 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.
- val
- Object
The design-time value of the variable.
Returns
The newly created variable that was added to the Variables collection.
Examples
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
Remarks
For more information, see Use Variables in Packages.