Home  +  Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Database~
~ C++ ~
~Contact~

SQL / C++ Tutorial using sqlwrapped

9. Delete a row from a database table

PreviousNextIndex This is another case where the execute() method on the Query class is used. example
int main() { StderrLog log; Database db("localhost", "root", "", "tutorialdb", &log); // MySQL specific if (!db.Connected()) { printf("Database not connected - exiting\n"); exit(-1); } Query q(db); long num_to_delete = q.get_count("select num from player where name='Lorangrym'"); if (num_to_delete) { char sql[1000]; sprintf(sql, "delete from player where num=%ld", num_to_delete); q.execute(sql); sprintf(sql, "delete from playerresource where player=%ld", num_to_delete); q.execute(sql); } }
example7_mysql.cppexample7_sqlite3.cpp
PreviousNext
Page, code, and content Copyright (C) 2021 by Anders Hedström