SQL Compact Database

The values of the variables are saved in a Microsoft SQL Compact database.
Microsoft SQL Server 2005 Compact Edition is a compact database, ideal for embedding in mobile and desktop applications. It offers developers a programming model common with other editions of SQL Server for developing system dedicated and managed applications. This SQL Server requires relatively few resources, but nevertheless provides the necessary functionality for relational databases such as a robust data store, an optimized query processor and reliable, scalable connection functions.

Compatible version: Microsoft Compact SQL Database 3.5

The variable values are saved in the following table structure.

Column name

Data type

Null permitted

Characteristic

ID

bigint

no

IDENTITY(1,1)

Timestamp

datetime

no

 

Name

ntext

no

 

ValueType = "Double"

Value

float

no

 

ValueType = "Bytes"

Value

image

no

 

An AutoID is generated in the "ID" column. The value in this column is, in other words, always increased by 1. This functionality makes the IDENTITY property possible.
The "Timestamp" column stores the time at which the data record was saved.
The name of the variable is stored in the "Name" column.
The "Value" column stores the value of the variable.

The table is created with the following SQL command:

/* ValueType = "Double"*/
CREATE TABLE myTable(
    ID          bigint IDENTITY(1,1)   NOT NULL,
    Timestamp   datetime               NOT NULL,
    Name        ntext                  NOT NULL,
    Value       float                  NOT NULL
)

/*ValueType = "Bytes"*/
CREATE TABLE myTable(
    ID          bigint IDENTITY(1,1)   NOT NULL,
    Timestamp   datetime               NOT NULL,
    Name        ntext                  NOT NULL,
    Value       image                  NOT NULL
)

E_DBColumnTypes

MS Compact SQL

PLC Control

eDBColumn_BigInt

bigint

T_ULARGE_INTEGER (TcUtilities.lib)

eDBColumn_Integer

integer

DINT

eDBColumn_SmallInt

smallint

INT

eDBColumn_TinyInt

tinyint

SINT

eDBColumn_Bit

bit

BYTE

eDBColumn_Money

money

LREAL

eDBColumn_Float

float

LREAL

eDBColumn_Real

real

REAL

eDBColumn_DateTime

datetime

DT

eDBColumn_NText

ntext

STRING

eDBColumn_NChar

nchar

STRING

eDBColumn_Image

image

ARRAY OF BYTE

eDBColumn_NVarChar

nvarchar

STRING

eDBColumn_Binary

binary

ARRAY OF BYTE

eDBColumn_VarBinary

varbinary

ARRAY OF BYTE

Important!
Do not save the database on the Compact Flash Card in case of an embedded system.
Either use the database in RAM, i.e. do not save to the "Hard disk" folder, or save on a network folder. To many write cycles to the Compact Flash Card can shorten its service life.