Search code examples
c++mysqlmysql-connectorconnector

Connector c++ res->getBoolean Acess Violation


I am using the mysql-connector-c++-1.1.4-winx64 in Visual Studio 2013. Connecting to a specific database and reading out Integer values works however it is impossible to retrieve any boolean value.
I can compile the program including the attached code but the program closes retrieving:

"The program '[3480] Project1.exe: Managed (v4.0.30319)' has exited with code -1073741819 (0xc0000005) 'Access violation'."

I appreciate any help!

                                    const char* idQuery = "SELECT EXISTS (SELECT id FROM experiment_results WHERE id='22');";
                                    stmt = con->createStatement();
                                    stmt->execute(idQuery);
                                    while (res->next()) 
                                    {
                                        bool flag = res->getBoolean(1);
                                    }

Solution

  • After looking again at the code I notice my mistake: stmt->execute(idQuery); // Should be: res = stmt->executeQuery(idQuery);