I tried to connect C++ to MySql and I just can\'t get this to work properly. I used latest MySql and C++/Connector for Windows from Oracle site. I also use VS2010.
I trial run the demo source codes from MySQL Connector/C++ Developer Guide / Getting Started with Connector/C++: Usage Examples / Complete Example 1 in the environment "mysql-connector-c++-8.0.13-win32" and Visual C++ 2015.
I also encountered the same problem.
In debug mode, it should use
std::string version = result->getString( COLUMN_NAME ).c_str();
But in release mode, this is OK:
sql::SQLString sString = result->getString( COLUMN_NAME );
I believe it is because my project must been compiled with the same runtime with the MySQL C++ Connector library.
The code below worked for me:
sql::ResultSet *res;
res->getString("Column name").c_str();
Just using res->getString("Column name")
was crashing my application.
I had a similar problem the program would give a memory exception. Here is what I did to fix it:
std::string version = result->getString( COLUMN_NAME ).c_str();
This didn't work:
sql::SQLString sString = result->getString( COLUMN_NAME ); <<<memory exception
std::string version = sString;
Are you sure task-column doesn't have the binary collation set? If so, the connector may return different metadata for the same column.
Update:
Also, check that the Connector has been compiled with the same runtime as your project. If using VS, I bet the other one was compiled with /MT and the other with /MD. This way, they use different heaps and it won't work.