Create a RealTimeSetRecord from a RealTimeRecord using the RealTimeRecord pointer
- Last UpdatedApr 08, 2026
- 1 minute read
This scenario guides you through the steps required to create a RealTimeSetRecord object from a RealTimeRecord.
To identify the code associated with each step, see the code comments in the Example code section.
To create a RealTimeSetRecord
- Open the Program.cs file from the created project.
- Open the RealTime database (RTDB).
- Lock the analog table for reading.
- Find the analog record to get its pointer name.
- Lock the analog record for reading.
- Get the record pointer.
- Create the RealTimeSetRecord object.
- Unlock the analog record.
- Unlock the analog table.
Example code:
IRealTimeDatabase database = new RealTimeDatabase();
try
{
// Open the RTDB.
if (!database.IsOpen())
{
database.Open();
}
using (IRealTimeTable table = new RealTimeTable("analog"))
{
ITableLockRequestType tableLockRequest = new TableLockRequestType();
IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
// Lock the analog table for reading.
table.Lock(tableLockRequest.SAFE_READ);
// Find the analog record.
var nameField = new RealTimeStringField(table, "name");
using (var record = table.FindRecord(nameField, "AutoCommandAnalog01"))
{
// Lock the analog record for read.
record.Lock(recordLockRequest.SAFE_READ);
// Get the record pointer.
var recPointer = record.HPDBRealTimeRecord.RecordPointer;
using (var setRecord = new RealTimeSetRecord((RealTimeSetTable)table.GetRealTimeSetTable(), recPointer))
{
// User code that uses the set record object
var desc = setRecord.ReadField<String>("description");
Console.WriteLine(quot;Description: {desc}");
}
} // Leaving scope releases the analog record lock.
} // Leaving scope releases the analog table lock.
}
catch (Exception ex)
{
Console.WriteLine(quot;Error getting the RealTimeSetRecord: {ex.Message}");
}