FB_DBCreate

FB_DBCreate 1:

The FB_DBCreate function block allows databases to be created.

The following database types can be created with this function block: MS SQL databases, MS SQL Compact databases, MS Access databases and XML databases

ASCII files can (but do not have to) be created with the function block FB_DBCreate. If they do not exist, they are created automatically during the first write access. They only have to be declared in the XML configuration file.

It is not possible to create DB2, Oracle, MySQL, PostgreSQL, InterBase and Firebird databases. In addition, it is not possible to overwrite existing databases. In this case the function block FB_DBCreate would return an error.

VAR_INPUT

VAR_INPUT
    sNetID      : T_AmsNetID;
    sPathName   : T_MaxString;
    sDBName     : T_MaxString;
    eDBType     : E_DBTypes;
    sSystemDB   : T_MaxString;
    sUserID     : T_MaxString;
    sPassword   : T_MaxString;
    bExecute    : BOOL;
    tTimeout    : TIME;
END_VAR

sNetID: String containing the AMS network ID of the target device, at which the ADS command is directed.

sPathName: Gives the path to the database.

sDBName: Gives the name of the database that is to be created.

eDBType: Gives the type of the database that is to be created.

sSystemDB: Only for Access databases. Contains the path to the MDW file.

sUserID: User name for the corresponding registration

sPassword: Corresponding password

bExecute: The command is executed with a rising edge.

tTimeout: Indicates the duration of the timeout.

VAR_OUTPUT

VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrID : UDINT;
END_VAR

bBusy: The command is in the process of being transmitted by ADS. No new command will be accepted as long as bBusy remains TRUE.

bError: Becomes TRUE, as soon as an error occurs.

nErrID: Returns the ADS error code if the bError output is set.

FB_DBCreate 2:

TwinCAT Database Server

If the newly created databases are to be used by the TwinCAT Database Server, the connection data have to be written to the XML configuration file with the aid of the function block FB_DBConnectionADD.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v3.0.0

PC or CX (x86)

Tc2_Database