# IOpcWriteNodesService Members

> Reference: Defines a specialized IOpcService<TResponse, TRequest> which can be used to write values to one or more attributes (see OpcAttribute) of one or more nodes.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">IOpcWriteNodesService</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.services">Opc.UaFx.Services</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Inherits members from [IOpcService&lt;OpcWriteNodesResponse, OpcWriteNodesRequest&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcservice-2/members).

## Properties

### MaxNodesPerWrite

<span class="api-meta">since v2.9</span>

Gets or sets the maximum number of nodes which shall be written using a single write request. This number indirectly defines the number of requests used to send a specific number of write requests to the server.

<div class="api-signature" data-lang="csharp">

```csharp
uint? MaxNodesPerWrite { get; set; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Property MaxNodesPerWrite As UInteger?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[UInt32](https://learn.microsoft.com/dotnet/api/system.uint32)&gt;

The absolute number of write commands which shall be send to the server per request or a null reference (Nothing in Visual Basic). In case there a specific number of nodes is used, a request with more commands as the [MaxNodesPerWrite](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcwritenodesservice/members#maxnodesperwrite) is partitioned into multiple requests and the responses of them are accumulated. The default value of this property is a null reference (Nothing in Visual Basic) and means that all commands defined are send to the server using the server defined number of nodes per write request.

### TimestampSource

Gets or sets the [OpcTimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctimestampsource/) to use to prepare [OpcValue](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcvalue/) timestamp values before sending a write request to a server.

<div class="api-signature" data-lang="csharp">

```csharp
OpcTimestampSource? TimestampSource { get; set; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Property TimestampSource As OpcTimestampSource?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcTimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctimestampsource/)&gt;

One of the members defined by the [OpcTimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctimestampsource/) enumeration; otherwise a null reference (Nothing in Visual Basic). In case there the value is null reference (Nothing in Visual Basic) there will be tried to automatically determine the timestamp sourcing to match the needs of the server. The default value of this property is a null reference (Nothing in Visual Basic).

### UsedMaxNodesPerWrite

<span class="api-meta">since v2.9</span>

Gets the maximum number of nodes which are written using a single write request. This property will use either the [MaxNodesPerWrite](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcwritenodesservice/members#maxnodesperwrite) or the maximum number of nodes which can be written in one request as defined by the server. The lowest number of nodes is used to partition the commands to execute into multiple write requests.

<div class="api-signature" data-lang="csharp">

```csharp
uint? UsedMaxNodesPerWrite { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
ReadOnly Property UsedMaxNodesPerWrite As UInteger?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[UInt32](https://learn.microsoft.com/dotnet/api/system.uint32)&gt;

In case there has already been one write attempt (with more than one write command) the definite number of commands per write request; otherwise a null reference (Nothing in Visual Basic).

### UsedTimestampSource

Gets the [OpcTimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctimestampsource/) currently used to prepare [OpcValue](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcvalue/) timestamp values before sending a write request to a server. In case there [TimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcwritenodesservice/members#timestampsource) is a null reference (Nothing in Visual Basic) this property will define the [OpcTimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctimestampsource/) automatically determined during the first write attempt which does write an [OpcValue](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcvalue/) of the [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#value) attribute.

<div class="api-signature" data-lang="csharp">

```csharp
OpcTimestampSource? UsedTimestampSource { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
ReadOnly Property UsedTimestampSource As OpcTimestampSource?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcTimestampSource](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctimestampsource/)&gt;

In case there has already been one write attempt to a [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#value) attribute the definite timestamp source; otherwise a null reference (Nothing in Visual Basic).

## Methods

### WriteNodes

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [WriteNodes(IEnumerable&lt;OpcWriteNode&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.services.iopcwritenodesservice/members#writenodes-system-collections-generic-ienumerable-of-opc-uafx-opcwritenode) | Writes one or more values to one or more attributes of one or more nodes using the specified `commands`. |
| [WriteNodes(params OpcWriteNode\[\])](#writenodes-opc-uafx-opcwritenode-array) | Writes one or more values to one or more attributes of one or more nodes using the specified `commands`. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The write service is currently not supported, especially using the `commands` specified. |
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | The service execution failed upon different circumstances; for more details see exception details. The following issues can lead to that exception: [BadNothingToDo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnothingtodo) and [BadTooManyOperations](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtoomanyoperations). |

#### WriteNodes(IEnumerable&lt;OpcWriteNode&gt;)

Writes one or more values to one or more attributes of one or more nodes using the specified `commands`.

<div class="api-signature" data-lang="csharp">

```csharp
OpcStatusCollection WriteNodes(IEnumerable<OpcWriteNode> commands)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Function WriteNodes(
    commands As IEnumerable(Of OpcWriteNode)) As OpcStatusCollection
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `commands` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcWriteNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcwritenode/)&gt; | A sequence of [OpcWriteNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcwritenode/) instances to process. |

**Returns**

[OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/)

An instance of the [OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/) its number and order of items matches the number and order of items in the `commands` sequence. There is for each command one entry which indicates the outcome of the operation for that command.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `commands` sequence or one of its items is a null reference (Nothing in Visual Basic). |

**Remarks**

Known results for the `commands` specified are:

| Status | Description |
|---|---|
| [GoodCompletesAsynchronously](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#goodcompletesasynchronously) | The value was successfully written to an intermediate system but the Server does not know if the data source was updated properly. |
| [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid) | For more details see [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid). |
| [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown) | For more details see [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown). |
| [BadAttributeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badattributeinvalid) | For more details see [BadAttributeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badattributeinvalid). |
| [BadIndexRangeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangeinvalid) | For more details see [BadIndexRangeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangeinvalid). |
| [BadIndexRangeNoData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangenodata) | For more details see [BadIndexRangeNoData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangenodata). |
| [BadWriteNotSupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badwritenotsupported) | The requested write operation is not supported. If a client attempts to write any value, quality, timestamp combination and the server does not support the requested combination (which could be a single quantity such as just timestamp), then the Server shall not perform any write on this node and shall return this status for that node. |
| [BadNotWritable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnotwritable) | For more details see [BadNotWritable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnotwritable). |
| [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied) | For more details see [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied). |
| [BadOutOfRange](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badoutofrange) | If a client attempts to write a value outside the valid range like a value not contained in the enumeration data type of a node, the server shall return this status for that node. |
| [BadTypeMismatch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtypemismatch) | For more details see [BadTypeMismatch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtypemismatch). |
| [BadDataEncodingUnsupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baddataencodingunsupported) | For more details see [BadDataEncodingUnsupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baddataencodingunsupported). |
| [BadNoCommunication](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnocommunication) | For more details see [BadNoCommunication](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnocommunication). |

#### WriteNodes(params OpcWriteNode\[\])

Writes one or more values to one or more attributes of one or more nodes using the specified `commands`.

<div class="api-signature" data-lang="csharp">

```csharp
OpcStatusCollection WriteNodes(params OpcWriteNode[] commands)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Function WriteNodes(
    ParamArray commands As OpcWriteNode()) As OpcStatusCollection
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `commands` | params [OpcWriteNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcwritenode/)[] | An array of [OpcWriteNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcwritenode/) instances to process. |

**Returns**

[OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/)

An instance of the [OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/) its number and order of items matches the number and order of items in the `commands`. There is for each command one entry which indicates the outcome of the operation for that command.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `commands` array or one of its items is a null reference (Nothing in Visual Basic). |

**Remarks**

Known results for the `commands` specified are:

| Status | Description |
|---|---|
| [GoodCompletesAsynchronously](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#goodcompletesasynchronously) | The value was successfully written to an intermediate system but the Server does not know if the data source was updated properly. |
| [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid) | For more details see [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid). |
| [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown) | For more details see [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown). |
| [BadAttributeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badattributeinvalid) | For more details see [BadAttributeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badattributeinvalid). |
| [BadIndexRangeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangeinvalid) | For more details see [BadIndexRangeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangeinvalid). |
| [BadIndexRangeNoData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangenodata) | For more details see [BadIndexRangeNoData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangenodata). |
| [BadWriteNotSupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badwritenotsupported) | The requested write operation is not supported. If a client attempts to write any value, quality, timestamp combination and the server does not support the requested combination (which could be a single quantity such as just timestamp), then the Server shall not perform any write on this node and shall return this status for that node. |
| [BadNotWritable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnotwritable) | For more details see [BadNotWritable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnotwritable). |
| [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied) | For more details see [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied). |
| [BadOutOfRange](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badoutofrange) | If a client attempts to write a value outside the valid range like a value not contained in the enumeration data type of a node, the server shall return this status for that node. |
| [BadTypeMismatch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtypemismatch) | For more details see [BadTypeMismatch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtypemismatch). |
| [BadDataEncodingUnsupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baddataencodingunsupported) | For more details see [BadDataEncodingUnsupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baddataencodingunsupported). |
| [BadNoCommunication](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnocommunication) | For more details see [BadNoCommunication](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnocommunication). |
