Nice!!
I will try your explanation in my test-bench, but just by looking at it, it
make sense.
Thanks Igor!!

-----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

Reply via email to