http://www.sqlite.org/cvstrac/wiki?p=ManagementTools Since there seems to be a confusion about the application I am using to view the newly created table and the data entered to it, I asked the question you are referring to in order to establish a common ground, an application to view the data in which we can discus on.
If you have an idea of a freeware I could use as a test bench, I would really appreciated if you let us know. TIA ----- Original Message ----- From: Pavel Ivanov Sent: 06/22/12 07:10 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] C++ programming - int sqlite3_prepare_v2() question > As I stated in my previous email, I used SQLight Designer to view the > database, which application would you recommend to view my database? This > question was asked million times on this list. Please search the archives. > Pavel On Fri, Jun 22, 2012 at 4:34 AM, Arbol One <arbol...@programmer.net> > wrote: > Thanks for the prompt response. > As I stated in my previous email, > I used SQLight Designer to view the database, which application would you > recommend to view my database? Please keep in mind that I am not able to > purchase a program, so it needs to be a free trial or a freeware. > On the > other hand, as far as you can see, should the code I have shown open a > database, create a table and then add data to the table? > > Thanks! > > > ----- Original Message ----- > From: Pavel Ivanov > Sent: 06/21/12 01:08 PM > > To: General Discussion of SQLite Database > Subject: Re: [sqlite] C++ > programming - int sqlite3_prepare_v2() question > > > Also, I have > downloaded and installed 'SQLight D esigner' and when opening the database file, I have just created, all that I can see is the words: SQLite format 3. Apparently you open your database file in some plain text editor instead of in something that understands what SQLite database is. Pavel On Thu, Jun 21, 2012 at 12:22 PM, Arbol One <arbol...@programmer.net> wrote: > namespace jme { > class Runner : public Gtk::Window { > private: > jme::Exception* e; // Exception handler > sqlite3 *db; // Data Base > sqlite3_stmt* stmt; // SQL statement > Glib::ustring dbName; // db name > Glib::ustring sName; // my name > Glib::ustring sAddress; // my address > Glib::ustring vfs; // MSWIN Identifier > int rc; // return code > int age; // my age > // SQL statement > Glib::ustring dbdata; > Glib::ustring create_table; > public: > Runner(); > ~Runner(); > void OpenDB(); > void CreateTable(); > void AddData(); > }; > } > void jme::Runner::CreateTable(){ > rc = sqlite3_prepare_v2( > > db, /* Database handle */ > create_table.c_str( ) , /* SQL statement, UTF-8 encoded */ > create_table.length(), /* Maximum length of zSql in bytes. */ > &stmt, /* OUT: Statement handle */ > NULL /* OUT: Pointer to unused portion of zSql */ > ); > if(rc != SQLITE_OK) { > sqlite3_close(db); > std::cout << "error prepare_v2: " << rc << std::endl; > exit(-2); > } > rc = sqlite3_step(stmt); > if(rc != SQLITE_DONE) { > sqlite3_close(db); > std::cout << "error sqlite3_step: " << rc << std::endl; > exit(-3); > } > sqlite3_finalize(stmt); > } > void jme::Runner::AddData(){ > rc = sqlite3_prepare_v2( > db, /* Database handle */ > dbdata.c_str() , /* SQL statement, UTF-8 encoded */ > dbdata.length(), /* Maximum length of zSql in bytes. */ > &stmt, /* OUT: Statement handle */ > NULL /* OUT: Pointer to unused portion of zSql */ > ); > if(rc != SQLITE_OK) { > .... > } > rc = sqlite3_step(stmt); > if(rc != SQLITE_DONE) { > .... > } > sqlite3_finalize(stmt); > } > void jme::Runner::OpenDB() > { > rc = sqlite3_open_v2(dbName.c_str(), > &d b, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, > NULL); > if(rc != SQLITE_OK) { > .... > } > jme::Runner::Runner() { > dbName = "sqliteTest.sql"; > sName = "ArbolOne"; > sAddress = "1 Parkway Rd"; > vfs = "win32"; > age = 22; > dbdata = "INSERT INTO friend VALUES('Jamiil', '49 New Bridge', '49')"; > create_table = "CREATE TABLE friend (name TEXT, address TEXT, age INT)"; > try { > jme::gnu_io f; > f.deleteFile(dbName); > } catch(jme::Exception e) { > std::cout << e.what() << std::endl; > } > OpenDB(); > CreateTable(); > AddData(); > > } > jme::Runner::~Runner(){ > sqlite3_close(db); > cout << "Good bye!" << endl; > } > int main(int argc, char *argv[]) { > try { > Gtk::Main kit(argc, argv); > jme::Runner dbtest; > Gtk::Main::run(dbtest); > } catch(jme::Exception& x) { > x.Display(); > } > return 0; > } > This is what I have done so far, and following your advice I hade added 'sqlite3_finalize(stmt)' each time I am done with it. Al > so, I have downloaded and installed 'SQLigh t Designer' and when opening the database file, I have just created, all that I can see is the words: SQLite format 3. > Come on you folk, you have more experience than me using SQLite, pich in!. What else do I need to do? > > TIA > > void jme::Runner::CreateTable(){ > rc = sqlite3_prepare_v2( > db, /* Database handle */ > create_table.c_str() , /* SQL statement, UTF-8 encoded */ > create_table.length(), /* Maximum length of zSql in bytes. */ > &stmt, /* OUT: Statement handle */ > NULL /* OUT: Pointer to unused portion of zSql */ > ); > if(rc != SQLITE_OK) { > sqlite3_close(db); > std::cout << "error prepare_v2: " << rc << std::endl; > exit(-2); > } > rc = sqlite3_step(stmt); > if(rc != SQLITE_DONE) { > sqlite3_close(db); > std::cout << "error sqlite3_step: " << rc << std::endl; > exit(-3); > } > sqlite3_finalize(stmt); > } > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http > ://sqlite.org:8080/cgi-bin/mailman/listi nfo/sqlite-users _______________________________________________ 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-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