Hi,
So I am importing the lines of a text file, editing the data a little and the inserting into a list in windows forms, thereafter I am writing the contents of this list to a local SQLite table but it is extremely slow - heres my code
SQLiteCommand insertTimesIntoTable = new SQLiteCommand("insert into tablePeopleTimes (firstname, lastname, empNo, tag, tlName, eName, clock, iOrO, terminalSN, terminalAdd) values (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9)", sqlCon);
for (int t = personTime.Count - 100; t < personTime.Count; t++)
{
string[] splitCurrent = personTime[t].Split(',');
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p0", splitCurrent[0]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p1", splitCurrent[1]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p2", splitCurrent[2]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p3", splitCurrent[3]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p4", splitCurrent[4]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p5", splitCurrent[5]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p6", splitCurrent[6]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p7", splitCurrent[7]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p8", splitCurrent[8]));
insertTimesIntoTable.Parameters.Add(new SQLiteParameter("@p9", splitCurrent[9]));
try
{
insertTimesIntoTable.ExecuteNonQuery();
//insertTimesIntoTable.ExecuteNonQueryAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
As you can see I have the prepared statement outside the for loop and have limited the writes to the last 100 items in the list but even this is extremely slow - any suggestions on how I could improve this?