Previous  Next

DatabaseOpen

Opens or creates a database in a specified file.

int  DatabaseOpen(
   string  filename,      // file name
   uint    flags          // combination of flags
   );

Parameters

filename

[in]  File name relative to the "MQL5\Files" folder.

flags

[in]  Combination of flags from the ENUM_DATABASE_OPEN_FLAGS enumeration.

Return Value

If executed successfully, the function returns the database handle, which is then used to access the database. Otherwise, it returns INVALID_HANDLE. To get the error code, use GetLastError(), the possible responses are:

Note

If the filename parameter features NULL or the empty string "", a temporary file is created on the disk. It is automatically deleted after closing the database connection.

If the filename parameter features ":memory:", the database is created in the memory and is automatically deleted after the connection to it is closed.

If the flags parameter features none of the DATABASE_OPEN_READONLY or DATABASE_OPEN_READWRITE flags, the DATABASE_OPEN_READWRITE flag is used.

If the file extension is not specified, ".sqlite" is used.

ENUM_DATABASE_OPEN_FLAGS

ID

Description

DATABASE_OPEN_READONLY

Read only

DATABASE_OPEN_READWRITE

Open for reading and writing

DATABASE_OPEN_CREATE

Create the file on a disk if necessary

DATABASE_OPEN_MEMORY

Create a database in RAM

DATABASE_OPEN_COMMON

The file is in the common folder of all terminals

See also

DatabaseClose