Connect database using VS Express 2013, MySQL Connector 1.1, C++

180 views Asked by At

I have a problem when try to connect database in MySQL. I'm using VS Express 2013. Here is my code:

// Project_Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>

/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "mysql_connection.h"
#include "mysql_driver.h"

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int main(void)
{
cout << endl;
cout << "Started";

try {
    sql::Driver *driver;
    sql::Connection *con;
    sql::Statement *stmt;
    sql::ResultSet *res;

    /* Create a connection */
    driver = get_driver_instance();
    con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
    /* Connect to the MySQL test database */
    con->setSchema("schema_test");

    stmt = con->createStatement();
    res = stmt->executeQuery("SELECT * FROM table_test");
    while (res->next()) {
        cout << "\t... MySQL replies: ";
        /* Access column data by alias or column name */
        cout << res->getString("Name") << endl;
    }
    delete res;
    delete stmt;
    delete con;

}
catch (sql::SQLException &e) {
    cout << "# ERR: SQLException in " << __FILE__;
    cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
    cout << "# ERR: " << e.what();
    cout << " (MySQL error code: " << e.getErrorCode();
    cout << ", SQLState: " << e.getSQLState() << " )" << endl;
}

cout << endl;

return EXIT_SUCCESS;
}

And I've got these error:

'Project_Test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file. 'Project_Test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file. 'Project_Test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file. 'Project_Test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120.dll'. Cannot find or open the PDB file. 'Project_Test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120.dll'. Cannot find or open the PDB file. The thread 0x17b4 has exited with code -1073741701 (0xc000007b). The thread 0xce4 has exited with code -1073741701 (0xc000007b). The thread 0x1440 has exited with code -1073741701 (0xc000007b). The program '[5652] Project_Test.exe' has exited with code -1073741701 (0xc000007b).

It show "The application was unable to start correctly..." when I run it. I've searched on Google for that, but there's no solution work. I think it's caused by the incompatibility between x64 & x86 libraries. I'm using MySQL Server & MySQL connector x86 but Visual Studio build for x64. I'vs tried to change Solution Platform in Configuration Manager but it's just have x64 platform, no choice for x86 platform. Is it an error of VS Express? Anyidea to solve this?

0

There are 0 answers