I'm working on a project where the user can insert a record into a SQLite database. The query will come generated automatically in the following method:
string ID = "";
string title = "";
string password = "";
cout << "Insert ID:\n";
cin >> ID;
cout << "Insert title of password:\n";
cin >> title;
cout << "Insert password:\n";
cin >> password;
string sql = "INSERT INTO test (ID,title,password) VALUES(" + ID + "," + title + "," + password + ");";
When i try to compile the program i get the error:
classes.h:74:76: error: invalid operands of types ‘const char*’ and ‘const char [2]’ to binary ‘operator+’
string sql = "INSERT INTO passwords (ID,title,password) VALUES (" + id + "," + title + "," + password
^
classes.h:78:42: error: invalid operands of types ‘int’ and ‘sqlite3_stmt*’ to binary ‘operator&’
sqlite3_prepare( db, sql.c_str(), -1 &st, NULL);
seem that he can't accept multiple character. Can someone show me how to fix this error?
P.S. I'm new in c++
Any help is appreciated. Thanks.
EDIT:
FULL CODE
sqlite3 *db;
sqlite3_stmt * st;
int id = 0;
string title = "";
string password = "";
cout << "Insert ID:\n";
cin >> id;
cout << "Insert title of password:\n";
cin >> title;
cout << "Insert password:\n";
cin >> password;
string sql = "INSERT INTO passwords (ID,title,password) VALUES (" + id + ',' + title + ',' + password + ");";
if(sqlite3_open("pw.db", &db) == SQLITE_OK)
{
sqlite3_prepare( db, sql.c_str(), -1 &st, NULL);
sqlite3_step( st );
}
else
{
cout << "Failed to connect\n";
}
sqlite3_finalize(st);
sqlite3_close(db);