dbTalk Databases Forums  

insert_id() returns 0

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss insert_id() returns 0 in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
greerde@gmail.com
 
Posts: n/a

Default insert_id() returns 0 - 10-14-2005 , 11:05 AM






Hopefully I'm making a silly mistake, but I am having problems with
insert_id().
Code:
Query query = con.query();
ostringstream strbuf;
strbuf.precision(12);
strbuf << "INSERT INTO ...."
query.exec(strbuf.str());
id = con.insert_id();

The query executes fine, but id is 0 at this point.

------------------------------

I am able to get insert_id() to work in dozens of other places in my
application where I do not need precision using the following code:
Query query = con.query();
query << "INSERT INTO ...";
query.execute();
id = con.insert_id();

So, What is the difference between the query.execute and
query.exec(str)?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.