OK, here I am again trying to find out how to create a table CreateTable() { create_table = "CREATE TABLE friend (name TEXT, address TEXT, age INT)";
rc = sqlite3_prepare_v2( db, create_table.c_str() , create_table.length(), &stmt, NULL ); .... rc = sqlite3_step(stmt); if(rc != SQLITE_DONE) { ... } /// the output here is 5, meaning SQLITE_NULL. The output should be 3 = SQLITE3_TEXT std::cout << sqlite3_column_type(stmt,0) << std::endl; sqlite3_finalize(stmt); } I checked my SQL statement and it is correct, why is SQLite reporting 5 when it is supposed to be 3? -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik Sent: Sunday, June 24, 2012 12:55 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] C++ programming - getting data from a table Arbol One <arbol...@gmail.com> wrote: > Thank you for the prompt response. Now, using simple std::cout, could > you show (give an example) of how to display (out streaming) the data extracted? sqlite3* db; sqlite3_open("db", &db); sqlite_stmt* stmt; sqlite3_prepare_v2(db, "select name, address, age from friend", -1, &stmt, NULL); while (sqlite3_step(stmt) == SQLITE_ROW) { cout << (char*)sqlite3_column_text(stmt, 0) << ' ' << (char*)sqlite3_column_text(stmt, 1) << ' ' << sqlite3_column_int(stmt, 2) << endl; } sqlite3_finalize(stmt); sqlite3_close(db); Error handling is left as an exercise for the reader. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users