gOPCClassicConnector.gWriteOneItem Method

Top  Previous  Next


Writes new value to a single OPC Item synchronously.

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


VB syntax

gOPCClassicConnector.gWriteOneItem(ByRef itemToWrite As gOPCClassicReadWriteObject)


C# syntax

gOPCClassicConnector.gWriteOneItem(ref gOPCClassicReadWriteObject itemToWrite)




A ReadWriteObject that specifies OPC Item you want to write to.


Return Type



C# code example



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

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

                read_write_obj.ItemID = txtItemID1.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.gOPCClassicFunctionResult function_result = gOPCClassicConnector1.gWriteOneItem(ref read_write_obj);


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

                //For a successfull write, function result should be "OK" , ResultID sould be "S_OK" 

                //For writing do not care "Quality


                txtFunctionResult.Text = function_result.ToString();

                txtResultID1.Text = read_write_obj.ResultID.ToString();


                if (function_result != GelecekCommon.gOPCClassicFunctionResult.OK || read_write_obj.ResultID != Opc.ResultID.S_OK)


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



            catch (Exception ex)