VB.Net write large amounts of data to SQLite-DB VB.Net write large amounts of data to SQLite-DB sqlite sqlite

VB.Net write large amounts of data to SQLite-DB


Executing thousands of inserts one after another is indeed insanely slow. It will help you tremendously to wrap all the inserts into a transaction.

Using t As SQLiteTransaction = sqlcon.BeginTransaction 'sqlcon being the SQLiteConnection    For Each row As string In t        line = Replace(row, "|", "','")        cmd.CommandText = cmd_string + line + "')"        cmd.ExecuteNonQuery()    Next                          t.Commit()End Using      

You basically collect all the inserts you want to do and when you are done they are all executed in one large swoosh. This speeds things up a lot.

Here is a tutorial on transactions:

http://www.tutorialspoint.com/sqlite/sqlite_transactions.htm