Re: [sqlite] C++ - nothing has been stored!!??

2012-07-25 Thread Eduardo Morras

At 03:27 25/07/2012, you wrote:

And here I am again, asking for what you find so easy and I. well, just
cannot understand.
...
but this does not store anything in the database table. I have used an
sqlite browser to determine if, in fact, some data was stored, but no,
nothing has been stored.

What am I doing wrong?



Where/when do you do the commit? 



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] C++ - nothing has been stored!!??

2012-07-24 Thread Igor Tandetnik

On 7/24/2012 9:27 PM, Arbol One wrote:

void mySQLite3Class::write(const Glib::ustring& sql_stmt, int pos,  int data
)throw(someException) {
 rc = sqlite3_prepare_v2(db, sql_stmt.c_str(), -1, , NULL);

 if(rc != SQLITE_OK) { throw(someException)}

 rc = sqlite3_bind_int(stmt, pos, data);

 if(rc != SQLITE_OK) { throw(someException)   }
}

but this does not store anything in the database table.


A hint: which SQLite API function does createTable() call but write() 
doesn't?


Also, don't forget to sqlite3_finalize all prepared statements once you 
are done with them.

--
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] C++ - nothing has been stored!!??

2012-07-24 Thread Arbol One
And here I am again, asking for what you find so easy and I. well, just
cannot understand.

I am trying to write to a database table previously created by another
process like this:

void someClass::create_tblName() {

sql_param_tblName = "CREATE TABLE name(n_id INTEGER PRIMARY KEY, title
TEXT, fname TEXT, mname TEXT, lname TEXT)";

try {db->createTable(sql_param_tblName); } catch(someException& e) {...}

}

void mySQLite3Class::createTable(const Glib::ustring& s) throw
(someException) {

rc = sqlite3_prepare_v2( db, s.c_str(), -1, , NULL);

if(rc != SQLITE_OK ) { throw someException }

rc = sqlite3_step(stmt);

if(rc != SQLITE_DONE) { throw someException }

}

}

 

The actual writing to the table looks like this:

 

void someClass::write2tblName() {

stmtName = "INSERT INTO name (n_id, title, fname, mname, lname) VALUES
(?, ?, ?, ?, ?)";

int data1 = 10;

int pos = 1;

try{db->write(stmtName,pos, data1);}catch(someException){.}

}

void mySQLite3Class::write(const Glib::ustring& sql_stmt, int pos,  int data
)throw(someException) {

rc = sqlite3_prepare_v2(db, sql_stmt.c_str(), -1, , NULL);

if(rc != SQLITE_OK) { throw(someException)}

rc = sqlite3_bind_int(stmt, pos, data);

if(rc != SQLITE_OK) { throw(someException)   }

 

}

 

but this does not store anything in the database table. I have used an
sqlite browser to determine if, in fact, some data was stored, but no,
nothing has been stored.

What am I doing wrong?

 

 

Leonardo da Vinci:
"I have offended God and mankind because my work did not reach the quality
it should have"

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users