I believe this will work if you put the SQL-required semi-colons at the end of your statements.
sql = "BEGIN;"; //you need to add newline here sql += "create table episodes (id integer primary key, season int, name text);"; sql += "insert into episodes(id, season, name) Values(1,2,'bill');"; sql += "insert into episodes(id, season, name) Values(2,3,'bob');"; sql += "COMMIT;"; I would say most people don't do this as any error returns won't tell you much. You'd normally prepare each seperately. Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate ________________________________ From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of e-mail mgbg25171 [mgbg25...@blueyonder.co.uk] Sent: Tuesday, June 21, 2011 6:22 AM To: sqlite-users@sqlite.org Subject: EXT :[sqlite] Howto...multi-sqlite command string through sqlite3_prepare_v2() to create SINGLE statement The commented out lines work. I'm wondering... a) is it possible to do what's not commented out b) what's the syntax re the "sql =..." and "sql +=..." lines Any help much appreciated! [code] //sql = "create table episodes (id integer primary key, season int, name text);"; ////rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail); ////replaced by //rc = sqlite3_prepare(db, sql.c_str(), strlen( sql.c_str() ), &stmt, &tail); //rc = sqlite3_step(stmt); // //sql = "insert into episodes(id, season, name) Values(1,2,'bill');"; ////rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail); ////replaced by //rc = sqlite3_prepare(db, sql.c_str(), strlen( sql.c_str() ), &stmt, &tail); //rc = sqlite3_step(stmt); // //sql = "insert into episodes(id, season, name) Values(2,3,'bob')"; ////rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail); ////replaced by //rc = sqlite3_prepare(db, sql.c_str(), strlen( sql.c_str() ), &stmt, &tail); //rc = sqlite3_step(stmt); sql = "BEGIN"; //you need to add newline here sql += "create table episodes (id integer primary key, season int, name text)"; sql += "insert into episodes(id, season, name) Values(1,2,'bill')"; sql += "insert into episodes(id, season, name) Values(2,3,'bob')"; sql += "COMMIT"; rc = sqlite3_prepare(db, sql.c_str(), strlen( sql.c_str() ), &stmt, &tail); rc = sqlite3_step(stmt); [code] _______________________________________________ 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