Hello, please help, it's been 4 days since i'm trying to work it out, after all the hours i spent on trying to link the libraries i'm honestly begging for help. First of all, what i did to install libraries:
1.) downloaded mysql-connector-c++-noinstall-1.1.0-win32 libraries from here:
http://download.softagency.net/MySQL/Downloads/Connector-C++/[
^] as they contain sqlstring dir.
2.) dowloaded boost libraries 1_49_0
Setting up the VS 2010:
1.) in properties -> general i set multi-byte char.
2.) in prop. -> C/C++ -> general i add paths to boost 1_49_0, connector folder ,,include" and connector folder ,,cppconn"
3.5.)i've added also the path to the C:\Program Files\MySQL\MySQL Server 5.5\lib, where libmysql.lib is-
3.) in prop. -> C/C++ -> preprocessor def. i added CPPCONN_PUBLIC_FUNC=
HAVE_INT8_T=1
4.) in prop. -> Linker -> i added path to the connector folder to the ,,lib" dir.
5.) in the Linker -> input i added additional dependencies: mysqlcppconn-static.lib
and libmysql.lib
In VS i'm running a new empty project - > C++ :
/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <winsock.h>
/*
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
#include
#include
#include
using namespace std;
int main(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://127.0.0.1:3306", "root", "root");
/* Connect to the MySQL test database */
con->setSchema("test");
stmt = con->createStatement();
res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
while (res->next()) {
cout << "\t... MySQL replies: ";
/* Access column data by alias or column name */
cout << res->getString("_message") << endl;
cout << "\t... MySQL says it again: ";
/* Access column fata by numeric offset, 1 is the first column */
cout << res->getString(1) << 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;
}
The errors i'm getting are:
Error 1 error C2001: newline in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 24
Error 2 error C2146: syntax error : missing ';' before identifier 'AS' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 3 error C2001: newline in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 4 error C2015: too many characters in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 5 error C2065: 'AS' : undeclared identifier c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 6 error C2146: syntax error : missing ';' before identifier '_message' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 7 error C2065: '_message' : undeclared identifier c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 8 error C2143: syntax error : missing ';' before 'constant' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 9 error C2143: syntax error : missing ';' before 'try' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 28
Error 10 error C2146: syntax error : missing ';' before identifier '»' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 57
Error 11 error C2065: '»' : undeclared identifier c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 57
12 IntelliSense: missing closing quote c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 24
13 IntelliSense: expected a ';' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
14 IntelliSense: missing closing quote c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
15 IntelliSense: identifier "stmt" is undefined c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 51
16 IntelliSense: identifier "con" is undefined c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 52
Please help me, what am i doing wrong, i've tried so many ways to figure it out but it is still not working :/