Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Automatic Data Type Conversion

Some automatic data type conversions may not be possible, and an error (CTDBRET_CANTCONVERT or CTDBRET_INVTYPE) will occur. This will happen, for instance, if the method CTRecord.SetFieldAsDate() is used to store data in a field whose type is CT_BOOL.

The table below presents the valid automatic conversions for the fields and the GetFieldAs...() or SetFieldAs...() methods.

Field Type*1

Function ...SetFieldAs... or ...GetFieldAs...

 

Signed

Unsigned

Bigint

Number

Float

Money

Currency

Date

Time

DateTime

String

Binary

Bool

Blob

CT_BOOL

X

X

X

X

 

 

X

 

 

 

*2

X

X

X

CT_TINYINT

X

X

X

X

 

 

X

 

 

 

X

X

X

X

CT_UTINYINT

X

X

X

 

 

 

 

 

 

 

X

X

X

X

CT_SMALLINT

X

X

X

X

 

X

X

 

 

 

X

X

X

X

CT_USMALLINT

X

X

X

 

 

 

 

 

 

 

X

X

X

X

CT_INTEGER

X

X

X

X

X

X

X

X

 

X

X

X

X

X

CT_UINTEGER

X

X

X

 

 

 

 

X

X

 

X

X

X

X

CT_MONEY

X

X

X

X

X

X

X

X

 

X

X

X

X

X

CT_DATE

X

X

X

 

 

 

 

X

 

 

X

X

X

X

CT_TIME

X

X

X

 

 

 

 

 

X

 

X

X

X

X

CT_FLOAT

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_DOUBLE

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_TIMESTAMP

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_EFLOAT

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_BINARY

X

X

X

X

X

X

X

X

X

 

X

X

 

X

CT_CHARS

X

X

X

X

X

X

X

X

X

X

X

X

 

X

CT_FPSTRING

X

X

X

X

X

X

X

X

X

X

X

X

 

X

CT_F2STRING

X

X

X

X

X

X

X

X

X

 

X

X

 

X

CT_F4STRING

X

X

X

X

X

X

X

X

X

 

X

X

 

X

CT_BIGINT

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_NUMBER

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_CURRENCY

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_PSTRING

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_VARBINARY

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_LVB

X

X

X

X

X

X

X

X

X

X

X

X

X

X

CT_VARCHAR or CT_LVC

X

X

X

X

X

X

X

X

X

X

X

X

X

X

*1 - These are the c-treeDB field types. The old c-tree Plus field types are also valid and may be used. For new projects, the best approach is to use the new field type convention presented in this table, since this is the naming convention for the FairCom DB SQL field types.

*2 - The value being set must be equal to either “TRUE” or “FALSE” (case insensitive), otherwise the function will fail with CTDBRET_CANTCONVERT (4042).

For every row in the table above, there is a highlighted column. This column represents the natural function that should be used to update that particular field. As discussed, though, any other function (column) marked with an “X” can be used, and the appropriate conversions will be performed.

TOCIndex