c# 4.0 - problem executing multiple SQLite statements from a single file -
i've been writing thin wrapper around sqlite using p/invoke, , i'd give ability read statements file (for bootstraps, etc.). wrote following in file:
create table test (col1 integer, col2 text); insert test (col1, col2) values (1, 'test1'); insert test (col1, col2) values (2, 'test2');
this file read via file.readalltext(), prepared via sqlite3_prepare(), , executed via sqlite3_step(). process has prepared , execute single-line sqlite statements.
what happens table created, neither insert statement run. need in order able insert multiple statements in single string?
figured out. turns out sqlite3_step() steps through 1 statement @ time. result, need call sqlite3_step() once each statement in string. gets little involved, since return code sqlite_done returns no matter how many statements you've executed; i'm doing semicolon count before execute string. alternatively, can use sqlite3_exec() if don't want deal looping business.
Comments
Post a Comment