Delete a record
- Last UpdatedApr 08, 2026
- 1 minute read
This scenario guides you through the steps required to delete an analog record in the RealTime database (RTDB).
To identify the code associated with each step, see the code comments in the Example code section.
To delete a record
- Open the Program.cs file from the created project.
- Open the RTDB.
- Access the analog table.
- Delete the record by using one of the following methods:
- Using the record number, if known.
table.DeleteRecord(28); - Getting the record by name.
- Lock the analog table for writing.
- Lock the record for writing.
table.Lock(tableLockRequest.SAFE_WRITE); var nameField = new RealTimeStringField(table, "name"); using (IRealTimeRecord record = table.FindRecord(nameField, "AnalogPoint_1")) { IRecordLockRequestType recordLockRequest = new RecordLockRequestType(); record.Lock(recordLockRequest.SAFE_WRITE); record.DeleteOnUnLock(); - Using the record number, if known.
- Unlock the record.
- Unlock the analog table.
Example code
IRealTimeDatabase database = new RealTimeDatabase();
try
{
// Open the RTDB
if (!database.IsOpen())
{
database.Open();
}
// Access the analog table.
using (IRealTimeTable table = new RealTimeTable("analog"))
{
// Delete the record.
ITableLockRequestType tableLockRequest = new TableLockRequestType();
// Lock the table for writing.
table.Lock(tableLockRequest.SAFE_WRITE);
var nameField = new RealTimeStringField(table, "name");
using (IRealTimeRecord record = table.FindRecord(nameField, "AnalogPoint_1"))
{
IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
// Lock the record for writing.
record.Lock(recordLockRequest.SAFE_WRITE);
record.DeleteOnUnLock();
} // Leaving scope releases the record lock.
} // Leaving scope releases the analog table lock.
}
catch (Exception ex)
{
Console.WriteLine(quot;Error deleting a record: {ex.Message}");
}