The c-treeDB .NET CTRecord class has the following methods to read field data from the record buffer:
Function Name |
Explanation |
---|---|
Read field data as any value depending on the overload |
|
GetFieldAsString() |
Read field data as string value |
To maintain compatibility with the "non .NET" c-treeDB API, the following other methods are available:
Function Name |
Explanation |
---|---|
GetFieldAsBool() |
Read field data as Boolean value |
GetFieldAsSigned() |
Read field data as signed integer value |
GetFieldAsUnsigned() |
Read field data as unsigned integer value |
GetFieldAsDate() |
Read field data as date value |
GetFieldAsTime() |
Read field data as time value |
GetFieldAsMoney() |
Read field data as money value |
GetFieldAsFloat() |
Read field data as double value |
GetFieldAsDateTime() |
Read field data as time stamp value |
GetFieldAsBinary() |
Read field data as binary data |
GetFieldAsBlob() |
Read field data as blob |
GetFieldAsBigint() |
Read field data as signed 64 bit integer |
GetFieldAsCurrency() |
Read field data as currency value |
GetFieldAsNumber() |
Read field data as number (BCD) value |
// display all field data on screen
void DisplayData(CTTable ATable, CTRecord ARecord)
{
int count = ATable.GetFieldCount();
int i;
string value;
for (i = 0; i < count; i++)
{
value = ARecord.GetFieldAsString(i);
Console.Write("Field {0}: {1}\n", i, value);
}
}
The following functions should be used to write fields into the data record buffer:
Function Name |
Explanation |
---|---|
update field data as any value depending on the overload |
|
SetFieldAsString() |
update field data as string value - deprecated: use SetFieldValue() |
To maintain compatibility with the "non .NET" c-treeDB API, the following additional methods are available, although they all are considered "obsolete" and should be replaced by SetFieldValue():
Function Name |
Explanation |
---|---|
SetFieldAsBool() |
update field data as Boolean value |
SetFieldAsSigned() |
update field data as signed integer value |
SetFieldAsUnsigned() |
update field data as unsigned integer value |
SetFieldAsDate() |
update field data as date value |
SetFieldAsTime() |
update field data as time value |
SetFieldAsMoney() |
update field data as money value |
SetFieldAsFloat() |
update field data as double value |
SetFieldAsDateTime() |
update field data as time stamp value |
SetFieldAsBinary() |
update field data as binary data |
SetFieldAsBlob() |
update field data as blob |
SetFieldAsBigint() |
update field data as signed 64 bit integer |
SetFieldAsCurrency() |
update field data as currency value |
SetFieldAsNumber() |
read field data as number (BCD) value |
// add new record
void AddRecord(CTRecord ARecord, string name, string address, string phone)
{
// clear the record buffer
ARecord.Clear();
// populate the record buffer with field data
ARecord.SetFieldAsString(0, name);
ARecord.SetFieldValue(1, address);
ARecord.SetFieldAsString(2, phone);
// add the new record
ARecord.Write();
}
The SetFieldAs...() and SetFieldValue() methods will also clear the null bit flag for the updated field.
When you invoke one of the old GetFieldAs...() methods, you pass the field number or field name and the method returns the data you want to read from the data record buffer.
When you invoke the GetFieldValue() method, you pass the field number or field name and the variable you want to contain the data you want to read from the data record buffer (marked as out).
When you invoke one of the SetFieldAs...() or SetFieldValue() methods, you pass the field number or field name and the data you want to write to the data record buffer.
If the type of the field you are trying to read from or write to is different from the type of the data specified by the GetField or SetField methods, the record manager will automatically convert the field data type to match the data type of the parameter passed by the GetField or SetField method.
For example, if you are writing a report generator application that displays the fields of a record on screen, you can read all fields in the record buffer with GetFieldAsString() and the record manager will convert the different field types to string. The boolean field type is converted as "True" or "False", numeric values are converted to strings, and dates and times use the session wide default date and time formats.