gOPCUAConnector.gReadOneItem Method

Top  Previous  Next


Reads value of a single  OPC Node from OPC Server synchronously.

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


VB syntax

gOPCUAConnector.gReadOneItem(ByRef itemToRead As gOPCUAReadWriteObject)


C# syntax

gOPCUAConnector.gReadOneItem(ref gOPCUAReadWriteObject itemToRead)




ReadWriteObject that holds NodeID you want to read.


Return Type



C# code example



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

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

                read_write_obj.NodeID = txtNodeID1.Text;


                //Step2: Run gReadOneItem method           

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


                //Step3: Check function result and item status code and get read value.

                //For a successfull read, 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)


                    //Show value on TextBox

                    //Be careful, Value should be able to convert to string..

                    txtValue1.Text = read_write_obj.Value.ToString();





            catch (Exception ex)