Create a record
- Last UpdatedApr 08, 2026
- 1 minute read
This scenario guides you through the steps required to create 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 create a record
- Open the Program.cs file from the created project.
- Open the RTDB.
- Access the analog table.
- Lock the analog record for writing.
- Create the record.
Where:- "Name" field is "AnalogPoint_1" (key field)
- "Description" field is "Description of AnalogPoint_1"
- Unlock the analog record.
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"))
{
// Lock the analog record for writing.
IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
// Create the record.
using (IRealTimeRecord record = table.CreateRecord("AnalogPoint_1"))
{
record.Lock(recordLockRequest.SAFE_WRITE);
record.WriteField<String>("description", "AnalogPoint_1 description");
} // Leaving scope releases the analog record lock.
}
}
catch (Exception ex)
{
Console.WriteLine(quot;Error creating a record: {ex.Message}");
}