User Ratings
Rate This Project
Login To Rate This Project
User Reviews
-
// a simple example to use SQLitePP void simple_example() { //define a connection SQLitePP::DBConnection conn; // connect to a database int rc = conn.connect("D:\\mytestdb.db"); if (rc != 0) { std::cout << conn.getErrorMessage() << std::endl; return; } // define a command and set a command text SQLitePP::DBCommand cmd(&conn); cmd.setCommandText("create table tbl_test(id integer not null, name text, contact text)"); rc = cmd.execute(); // execute if (rc != 0) { std::cout << conn.getErrorMessage() << std::endl; return; } // insert data cmd.setCommandText("insert into tbl_test(id, name, contact) values(0, 'gavin', 'vxling@gmail.com')"); rc = cmd.execute(); // execute if (rc != 0) { std::cout << conn.getErrorMessage() << std::endl; return; } // execute a query cmd.setCommandText("select * from tbl_test"); rc = cmd.execute(); // execute if (rc != 0) { std::cout << conn.getErrorMessage() << std::endl; return; } // print all result while (cmd.fetchNext()) { std::cout << cmd.field(0) << ", " << cmd.field(1) << std::endl; } }
- Previous
- You're on page 1
- Next