# mco_db_connect
RT

> Connect to a database.

### Prototype

        MCO_RET	mco_db_connect(	/*IN*/ const char * dbname, /*OUT*/ mco_db_h *db);

### Arguments

dbname | The name of the database to connect to
db | The address of a database handle for this database connection

### Description

> This function connects an application (thread) to a database. The database must have been previously opened by `mco_db_open()`. It returns a connection handle that is passed to the other API functions to access the database.

### Return Codes

MCO_S_OK | The database was created successfully
MCO_E_NOINSTANCE | The specified database is not opened

### Example

        Application snippet:

        const char * dbname = "SimpleDb";

        int main(int argc, char* argv[])
        {
            mco_db_h db;
            MCO_RET rc;
            mco_device_t       dev;
            mco_db_params_t    db_params;

            ...
            rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params );
            if ( MCO_S_OK != rc )
            {
                rc = mco_db_connect(  dbname, &db );

                ...
            }
            ...
        }

### Files

Header file:
mco.h
Source file:
mcoabst.c
Library:
libmcolib.a