MySQL Forums
Forum List  »  Connector/C++

[HELP - S.O.S.] WINXP + VS 2008 + C++ = Uncontrolled Exception
Posted by: imanol muñoz pandiella
Date: July 28, 2009 03:32AM

Hello, i need urgent help because i'm obtaining a error that i don't understand.

I have to develop a win 32 application that connects to a mysql bd. After try to develop with some IDE i have decided to develop with Visual Studio 2008 because i want to use qt interfaces and VS 2008 have an add-in with this purpose.

I have followed the instalation process of the web:

And i have tryed the complete example of this page:

Here start the problems. Firts of all i have tryed to run this example with visual c++ 2008 express edition and everything runs ok. Then i have tryed to develop an example with qt libraries in visual c++ and i get some problems with it. So i find that there is and add-in to use qt with the complete visual studio. And i tryed and it works perfect. The problem is when i try to use the example of mysql with microsoft visual studio 2008. When i develop the example i get this error:

"Exception not controlled in 0x0042e081 in prueba2.exe: 0xC0000005: Acces infraction when reading the ubication 0x0000000f."

I don't understant why works on visual c++ 2008 and not in visual studio 2008... I do everything equals in both versions... Trying to resolve this i add a catch at the code (you can see the code at the end of the post), but there weren't satisfactory results.

Thank you very much, i hope to somebody helps me!!!


// prueba2.cpp: define el punto de entrada de la aplicación de consola.

#include "stdafx.h"

/*int _tmain(int argc, _TCHAR* argv[])
return 0;

/* Copyright 2008 Sun Microsystems, Inc.

This program is free software; you can redistribute it and/or modify
it under only the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.

There are special exceptions to the terms and conditions of the GPL
as it is applied to this software. View the full text of the
exception in file EXCEPTIONS-CONNECTOR-C++ in the directory of this
software distribution.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

/* 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 <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int _tmain(void)
cout << endl;
cout << "Running 'SELECT 'Hello World!' AS _message'..." << endl;

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

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

stmt = con->createStatement();
res = stmt->executeQuery("SELECT * FROM autores");
while (res->next()) {
cout << "\t... MySQL replies: ";
/* Access column data by alias or column name */
cout << res->getString("nombre") << endl;
cout << "\t... MySQL says it again: ";
/* Access column fata by numeric offset, 1 is the first column */
cout << res->getString("user") << 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;
} catch (std::exception &e){
cout<< "excetpion";

cout << endl;


Options: ReplyQuote

Written By
[HELP - S.O.S.] WINXP + VS 2008 + C++ = Uncontrolled Exception
July 28, 2009 03:32AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.