> while ( sqlite3_step(stmt) != SQLITE_ROW) { > sName = (char*)sqlite3_column_text(stmt, 0); //<== Seg fault > std::cout << sName << std::endl; > ... > }
You can only access columns when you have a row, not when you don't. --- () ascii ribbon campaign against html e-mail /\ www.asciiribbon.org > -----Original Message----- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > boun...@sqlite.org] On Behalf Of Arbol One > Sent: Monday, 25 June, 2012 07:27 > To: General Discussion of SQLite Database > Subject: Re: [sqlite] C++ programming - Extracting data > > Sorry, I forgot to give you a snip of the test-bench code > > getter() { > string sName; > string sAddress; > int age = 0; > string dbdata = "SELECT * FROM friend"; > > rc = sqlite3_prepare_v2(db, dbdata.c_str(), -1, &stmt, NULL ); > .... > rc = sqlite3_step(stmt); > if(rc != SQLITE_DONE) { ... } > while ( sqlite3_step(stmt) != SQLITE_ROW) { > sName = (char*)sqlite3_column_text(stmt, 0); //<== Seg fault > std::cout << sName << std::endl; > ... > } > sqlite3_finalize(stmt); > } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users