You need to invoke sqlite3_finalize() on the prepared statement when you are finished using it, before the function returns.