gOPCUAConnector.gWriteOneItem Method

Top  Previous  Next


Writes new value to a single OPC Node synchronously.

This synchronous operation may freeze your application until the end of operation.


VB syntax

gOPCUAConnector.gWriteOneItem(ByRef itemToWrite() As gOPCUAReadWriteObject)


C# syntax

gOPCUAConnector.gWriteOneItem(ref gOPCUAReadWriteObject itemToWrite)




ReadWriteObject that holds NodeID and value you want to write.


Return Type



C# code example



                //Step1: Create a read-write object , assign NodeID and assign value to write

                GelecekCommon.gOPCUAReadWriteObject read_write_obj = new GelecekCommon.gOPCUAReadWriteObject();

                read_write_obj.NodeID = txtNodeID1.Text;

                read_write_obj.Value = txtValue1.Text;  //Be careful Text should be able to convert to data type of OPC Node


                //Step2: Run gWriteOneItem method 

                GelecekCommon.gOPCUAStatusCode function_result = gOPCUAConnector1.gWriteOneItem(ref read_write_obj);


                //Step3: Check function result and status code to be sure about a successfull writing

                //For a successfull write, function result should be "Good" , status code sould be "Good" 


                txtFunctionResult.Text = function_result.ToString();

                txtStatusCode1.Text = read_write_obj.StatusCode.ToString();


                if (function_result != GelecekCommon.gOPCUAStatusCode.Good || read_write_obj.StatusCode != GelecekCommon.gOPCUAStatusCode.Good)


                    MessageBox.Show("OPC UA Connector Tutorial Project: Error in writing");



            catch (Exception ex)