I would like to know how to get the time needed by the
INSERT
query in a msaccess database.
I use an OleDbCommand and of course an OleDbConnection object
I am running a loop like :
For Each item In ListBox.SelectedItems
Try
cmd.CommandText = "INSERT INTO table(x) VALUES(" + item.ToString + ")"
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Next
and just afterwards I fill another listbox by getting these items recently inserted in the database.
code for 2nd listbox:
SELECT items FROM table
for each item returned by query:
listbox2.addItem(item)
end loop
I have a slow connection so my 2nd listbox doesn't get filled right away.
By putting my thread to sleep for 5s and then running the SELECT
query solves my problem because only after 5s I can see the newly inserted data, but it's not always like this, I may need to wait for 4s or even 7s.I hope the Try
does not slow down the process.