I would try using a data table - it should run faster.
Say, try like this:
Dim sqlCon As New OleDbConnection(My.Settings.AccessDB)
Dim strSql As String = "SELECT * FROM tblBig WHERE ID = 0"
Dim cmdSQL As New OleDbCommand(strSQL, sqlCon)
Dim rstData = New DataTable
sqlCon.Open()
rstData.Load(cmdSQL.ExecuteReader)
Dim da As New OleDbDataAdapter(cmdSQL)
Dim daU As New OleDbCommandBuilder(da)
Dim stop_watch_1 As New Stopwatch
Dim getDate As Date = Date.Now
stop_watch_1.Start()
For i As Integer = 1 To 10000
Dim MyNewRow = rstData.NewRow
MyNewRow("City") = "City" & i
MyNewRow("FirstName") = "FirstName " & i
MyNewRow("LastName") = "LastName " & i
rstData.Rows.Add(MyNewRow)
If (i Mod 500) = 0 Then
'Debug.Print("data write" & stop_watch_1.ElapsedMilliseconds / 1000)
da.Update(rstData)
rstData.Clear()
End If
Next
' write data back to database
da.Update(rstData)
sqlCon.Close()
stop_watch_1.Stop()
MsgBox("Row(s) Inserted !! - " & stop_watch_1.ElapsedMilliseconds / 1000)
I have it set to write out in above every 500 rows.
However, you are getting about 1,000 rows per second, and I not at all sure you going to increase that rate - it is VERY good rates you already seeing, and I can't say the above is going to help much.
edit: I feel the need for speed!!! SUPER FAST!!!
Ok, if you want to bring this down from 10 seconds to 1/3 of a second?
by-pass the .net providers. Hit the database DIRECT with the native DAO object library. You get about 30 times faster.
So, try this:
Imports Microsoft.Office.Interop.Access
and then do this:
Dim dbE As New Dao.DBEngine
Dim db As Dao.Database
db = dbE.OpenDatabase("C:\test\test44.accdb")
Dim rstData As Dao.Recordset
rstData = db.OpenRecordset("tblBig")
Dim stop_watch_1 As New Stopwatch
stop_watch_1.Start()
For i As Integer = 1 To 10000
rstData.AddNew()
rstData("City").Value = "City" & i
rstData("FirstName").Value = "FirstName " & i
rstData("LastName").Value = "LastName " & i
rstData.Update()
Next
db.Close()
stop_watch_1.Stop()
MsgBox("Row(s) Inserted !! - " & stop_watch_1.ElapsedMilliseconds / 1000)
You find a min of 30x faster - even more. So, DIRECT use of the data engine, and by-passing all of the .net providers? You EASY insert 10,000 rows in WELL UNDER 1 second.