I have a MySQL database with a table containing a BINARY(16) column.
When I write binary data via ODBC from my C++ application, the data is treated like a Null-terminated string, i.e. it is truncated at the first Null byte in the data.
In my C++ application I bind an unsigned char [16] array using SQLBindParameter like this:
SQLBindParameter(statementHandler, paramCount, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_BINARY, MAX_NOTIFICATION_OUT_IP_BIN_LEN, 0, _notificationOutDstIP, MAX_NOTIFICATION_OUT_IP_BIN_LEN, 0);
MAX_NOTIFICATION_OUT_IP_BIN_LEN is 16.
How can I make sure that 16 bytes are written to the database, even if the binary data contains Null values?
From the MSDN documentation for
SQLBindParameter:Instead, set that argument to be a pointer to the data length: