From: Graham Reitz Date: August 11 2007 6:26am Subject: Inserting with a column that uses auto_increment List-Archive: http://lists.mysql.com/plusplus/6914 Message-Id: MIME-Version: 1.0 (Apple Message framework v752.3) Content-Type: multipart/alternative; boundary=Apple-Mail-4-200502585 --Apple-Mail-4-200502585 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed How do you prevent an insert as shown in the code below from putting "bogus" data in an auto_increment field? It seems like the billing_id field, in the code below, inserts a number based on the un-initialized value of client_id, instead of letting the database auto_increment the value. What's a good method to deal with this, that allows the database to auto_increment a database field? Thanks, Graham /************ CODE ************/ #include #include using namespace mysqlpp; sql_create_2(clients, 1, 2, unsigned int, client_id, // auto_incremented field unsigned int, billing_id) void populate_client_info(clients& client_info) { client_info.billing_id = 1; } int main (int argc, char* const argv[]) { Connection connection("db_name","ip_address","user", "password",3306, false); Query client_query = connection.query(); clients a_client; populate_client_info(a_client); client_query.insert(a_client); client_query.execute(); return 0; } --Apple-Mail-4-200502585--