DB2Parameter.ArrayLength Property

Gets or sets the number of elements of the Value property to use for parameter bind-in.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Property ArrayLength As Integer
[C#]
public int ArrayLength {get; set;}
[C++]
public: __property int get_ArrayLength();
public: __property void set_ArrayLength(int);
[JScript]
public function get ArrayLength() : int;
public function set ArrayLength(int);

Property value

The number of elements stored in the Value property used for parameter bind-in. The default value is 0.

Remarks

When an array type is provided as a bind-in value in the Value property, the ArrayLength property indicates how many elements from that array are to be used in bind-in. An exception will be generated when Value is set to a value that is less than 0 or greater than the Length of the array.

When ArrayLength is not set, or is set to 0, and an array type is given as a bind-in value in the Value property then the data provider will behave the same as it did before the implementation of ArrayLength - for single dimensional Char and Byte arrays, the entire length of the data is sent to the server; an exception is thrown in all other cases. When ArrayLength is set to a valid value, but the bind-in value is not an array type, a casting exception will be generated.

Single dimensional arrays of all .NET data types are supported. Arrays of Objects and DB2Types are not supported. See the topic DB2Type Enumeration for a comparison of the different data types.

The ArrayLength property applies only when binding values for Array data types.

Example

[Visual Basic, C#] The following example creates a DB2®Parameter and sets some of its properties.

[Visual Basic]
Public Sub CreateDB2Parameter()
    Dim myValue() As String = {"first string", "second string", "third string"}
    Dim myParameter As New DB2Parameter("Description", DB2Type.VarChar)
    myParameter.Direction = ParameterDirection.Input
    myParameter.Value = myValue
    myParameter.ArrayLength = myValue.Length
End Sub 'CreateAdoParameter

[C#]
public void CreateDB2Parameter()
 {
    string[] myValue = new string[] {"first string", "second string", "third string"}
    DB2Parameter myParameter = new DB2Parameter("Description", DB2Type.VarChar);
    myParameter.Direction = ParameterDirection.Input;
    myParameter.Value = myValue;
    myParameter.ArrayLength = myValue.Length;
 }