# MySQL\_Open

## `MySQL_Open` (FB)

FUNCTION\_BLOCK MySQL\_Open

**Short description:**

> This function block opens the MySQL connection.

**Detailed description:**\
The opening process starts with a rising edge of "xStart". The variable "xStart" is reset at the end of the process.\
If an error occurs during the opening process, an ERROR code and the current execution state are shown, which helps identify the problem.

InOut:

| Scope  | Name               | Type                    | Initial | Comment                                                                        |
| ------ | ------------------ | ----------------------- | ------- | ------------------------------------------------------------------------------ |
| Input  | `sHost`            | `STRING`                |         | MySQL server hostname or IP address                                            |
| Input  | `uiPort`           | `UINT`                  | 3306    | MySQL server port (Default: 3306)                                              |
| Input  | `sDatabase`        | `STRING`                |         | MySQL database name                                                            |
| Input  | `sUsername`        | `STRING`                |         | MySQL database user                                                            |
| Input  | `sPassword`        | `STRING`                |         | MySQL user password                                                            |
| Inout  | `xStart`           | `BOOL`                  |         | Start execution on a rising edge                                               |
| Inout  | `MySQL_Connection` | MySQL\_ConnectionString |         | <p>MySQL connection string which holds the server and login<br>information</p> |
| Output | `xConnected`       | `BOOL`                  |         | TRUE when connected                                                            |
| Output | `eError`           | ERROR                   |         | Error type                                                                     |
| Output | `sExeute_State`    | `STRING(200)`           |         | Current execute state                                                          |
