I got a little problem I am making a little admin tool for my server that you can edit player stats and things with it.
Problem is if I like make string Test and assign value "Hi" to it.
How can I use the string inside my IMPORT INTO statement.
Here's code:
#include <stdlib.h>
#include <iostream>
#include "mysql_connection.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;
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "*******");
stmt = con->createStatement();
stmt->execute("USE breakpoint");
string Test = "Hi";
stmt->execute("INSERT INTO characters(Name, CID, Age, Char_Strength, Char_Speed, Char_Endurance, Char_Aim, Char_RunningEndurance, Blackmarket, Business, Electronics, Food, Misc, Money, Inventory_room, Model, Title) VALUES ('Test Name', '45264', 20,'20','20','20','20','20','1','1','1','1','1',599,500,'lol','Lol')");
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;
}
You see string test how would I like put it to replace "Test name" part, It doesnt work like this:
#include <stdlib.h>
#include <iostream>
#include "mysql_connection.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;
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "*******");
stmt = con->createStatement();
stmt->execute("USE breakpoint");
string Test= "Hi";
stmt->execute("INSERT INTO characters(Name, CID, Age, Char_Strength, Char_Speed, Char_Endurance, Char_Aim, Char_RunningEndurance, Blackmarket, Business, Electronics, Food, Misc, Money, Inventory_room, Model, Title) VALUES (Test, '45264', 20,'20','20','20','20','20','1','1','1','1','1',599,500,'lol','Lol')");
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;
}
Sorry for bad explanation but try to understand it please