Hi,
I'm trying to create a table lambda from the MySQL Connector C++ by two different ways.
On the one hand, I'm passing a string, defined at a different line, to the execute() member of the statement class, and this results in crashing my application.
string rq= "CREATE TABLE lambda (id INT)";
stmt->execute(rq);
On the other hand, I successfully create my table by directly writing:
stmt->execute("CREATE TABLE lambda (id INT)");
This means I can see that a table has been created by executing the commands:
USE test
SHOW TABLES;
Could anybody help me out ?
Settings:
- I'm using VS2010/MySQL Connector C++ 1.1.0/MySQL Server 5.1
- I have followed the instructions http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-apps-windows-visual-studio.html.
- I'm not completely familiar to C++.
- Common coding is:
#include "StdAfx.h"
#include <string>
#include <mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/sqlstring.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
int main(void)
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
try {
driver = get_driver_instance();
con = driver->connect("tcp://localhost:3306/test", "root", "password");
[...]
delete stmt;
delete con;
} catch (sql::SQLException e) {
cout << "Error " << e.getErrorCode() << ": " <<e.what();
}
return 0;
}
I'm trying to create a table lambda from the MySQL Connector C++ by two different ways.
On the one hand, I'm passing a string, defined at a different line, to the execute() member of the statement class, and this results in crashing my application.
string rq= "CREATE TABLE lambda (id INT)";
stmt->execute(rq);
On the other hand, I successfully create my table by directly writing:
stmt->execute("CREATE TABLE lambda (id INT)");
This means I can see that a table has been created by executing the commands:
USE test
SHOW TABLES;
Could anybody help me out ?
Settings:
- I'm using VS2010/MySQL Connector C++ 1.1.0/MySQL Server 5.1
- I have followed the instructions http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-apps-windows-visual-studio.html.
- I'm not completely familiar to C++.
- Common coding is:
#include "StdAfx.h"
#include <string>
#include <mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/sqlstring.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
int main(void)
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
try {
driver = get_driver_instance();
con = driver->connect("tcp://localhost:3306/test", "root", "password");
[...]
delete stmt;
delete con;
} catch (sql::SQLException e) {
cout << "Error " << e.getErrorCode() << ": " <<e.what();
}
return 0;
}