MySql C++ connector getString() doesn't work correctly, while getInt works perfectly

后端 未结 4 2017
轻奢々
轻奢々 2021-01-20 04:18

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.

4条回答
  •  不知归路
    2021-01-20 04:40

    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.

提交回复
热议问题