Re: [sqlite] SQLite under c++
"Juzbrig" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ok it works but how do I get messages/errors back from DB? Because > now im doing it blind. You check return value for error code. If you got one, you call sqlite3_errmsg[16] for an error message. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLite under c++
Ok it works but how do I get messages/errors back from DB? Because now im doing it blind. Mike Marshall wrote: > > Do something like this > > sqlite3_stmt* pStatement; > vector vResults; > int nError = sqlite3_prepare_v2(pHandle,"SELECT col1 FROM > table",-1,&pStatement,NULL); > while (sqlite3_step(pStatement) == SQLITE_ROW) > { > > vResults.push_back((char*)sqlite3_column_text(pStatement, 0)); > } > sqlite3_finalize(pStatement); > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Juzbrig > Sent: 23 July 2008 13:31 > To: sqlite-users@sqlite.org > Subject: [sqlite] SQLite under c++ > > > Hi. > I am new in sqlite (before I have mysql + php experience). I have a > question > > If my DB is alredy open > > sqlite3* handle; > const char* baza = "cols.db3" ; > char *zErrMsg = 0; > sqlite3_open(test_baza,&handle); > > How can I get the results of SQL "SELECT * FROM" into a string table or > any > c++ structure ? > sqlite3_exec() doesn't seem to return any strings/chars. > > If anyone could write me that in code I would be grateful. > -- > View this message in context: > http://www.nabble.com/SQLite-under-c%2B%2B-tp18609682p18609682.html > Sent from the SQLite mailing list archive at Nabble.com. > > ___ > 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 > > -- View this message in context: http://www.nabble.com/SQLite-under-c%2B%2B-tp18609682p18628239.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLite under c++
Juzbrig <[EMAIL PROTECTED]> wrote: > I am new in sqlite (before I have mysql + php experience). I have a > question If my DB is alredy open > > sqlite3* handle; > const char* baza = "cols.db3" ; > char *zErrMsg = 0; > sqlite3_open(test_baza,&handle); > > How can I get the results of SQL "SELECT * FROM" into a string table > or any c++ structure ? > sqlite3_exec() doesn't seem to return any strings/chars. http://sqlite.org/c3ref/free_table.html But it's better to use prepared statement APIs: sqlite3_prepare[_v2], sqlite3_step, sqlite3_column_*, sqlite3_finalize. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLite under c++
Do something like this sqlite3_stmt* pStatement; vector vResults; int nError = sqlite3_prepare_v2(pHandle,"SELECT col1 FROM table",-1,&pStatement,NULL); while (sqlite3_step(pStatement) == SQLITE_ROW) { vResults.push_back((char*)sqlite3_column_text(pStatement, 0)); } sqlite3_finalize(pStatement); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juzbrig Sent: 23 July 2008 13:31 To: sqlite-users@sqlite.org Subject: [sqlite] SQLite under c++ Hi. I am new in sqlite (before I have mysql + php experience). I have a question If my DB is alredy open sqlite3* handle; const char* baza = "cols.db3" ; char *zErrMsg = 0; sqlite3_open(test_baza,&handle); How can I get the results of SQL "SELECT * FROM" into a string table or any c++ structure ? sqlite3_exec() doesn't seem to return any strings/chars. If anyone could write me that in code I would be grateful. -- View this message in context: http://www.nabble.com/SQLite-under-c%2B%2B-tp18609682p18609682.html Sent from the SQLite mailing list archive at Nabble.com. ___ 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
[sqlite] SQLite under c++
Hi. I am new in sqlite (before I have mysql + php experience). I have a question If my DB is alredy open sqlite3* handle; const char* baza = "cols.db3" ; char *zErrMsg = 0; sqlite3_open(test_baza,&handle); How can I get the results of SQL "SELECT * FROM" into a string table or any c++ structure ? sqlite3_exec() doesn't seem to return any strings/chars. If anyone could write me that in code I would be grateful. -- View this message in context: http://www.nabble.com/SQLite-under-c%2B%2B-tp18609682p18609682.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users