Have a vb6 program that was connecting to an Access 97 database. We have converted the database to Access 2003 and changed the provider to use Jet 4.0
Now we are running into Could not update; Currently Locked when we are trying to add records to a table. Here is the code inserting records into the database. It works 95% of the time but if we are inserting a lot of data, it starts to get record locks.
Public Sub Store(Conn As ADODB.Connection, Day As Date, _
nType As cNodeType, ID As Long, Name As String, _
Origin As String, Location As String, Forecast As Variant)
Dim Stored As New ADODB.Recordset
Dim i As Integer
Dim iReSave As Boolean
On Error GoTo ErrorOnSave
Stored.Open "forecasts", _
Conn, adOpenStatic, adLockOptimistic
Stored.AddNew
Stored!Updated = Now
Stored!Date = Day
Stored!Type = nType
Stored!ID = ID
Stored!Name = Name
Stored!Origin = Origin
Stored!Location = Location
For i = 0 To 95
Stored.Fields(i + 7).Value = Forecast(i, 0)
Next
Stored.Update
Stored.Close
End Sub