I am using ADODB Connection Object in my code. But after successfully running my code shown below I get this runtime error message:
"The database has been placed in a state by user 'Admin' on machine 'JH' that prevent it from being opened or locked.
When I close the database and open it again ,,, the code runs fine for few times and then after that it starts giving me the same error message. This thing is driving me crazy. Any ideas/thoughts?
Thanks in advance.
jay
Dim cnConnection As ADODB.Connection
Set cnConnection = New ADODB.Connection
Dim strConnection As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentProject.Path & "\AutoUpdate.mdb;"
cnConnection.Open strConnection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.LockType = adLockBatchOptimistic
rst.Open "SELECT * FROM TestTable", cnConnection
Set cnConnection = Nothing
rst.MoveFirst
With rst
Do While Not rst.EOF
.Fields(1) = 100
.Update
.MoveNext
Loop
End With
Set cnConnection = New ADODB.Connection
cnConnection.Open strConnection
rst.UpdateBatch
End Function
"The database has been placed in a state by user 'Admin' on machine 'JH' that prevent it from being opened or locked.
When I close the database and open it again ,,, the code runs fine for few times and then after that it starts giving me the same error message. This thing is driving me crazy. Any ideas/thoughts?
Thanks in advance.
jay
Dim cnConnection As ADODB.Connection
Set cnConnection = New ADODB.Connection
Dim strConnection As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentProject.Path & "\AutoUpdate.mdb;"
cnConnection.Open strConnection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.LockType = adLockBatchOptimistic
rst.Open "SELECT * FROM TestTable", cnConnection
Set cnConnection = Nothing
rst.MoveFirst
With rst
Do While Not rst.EOF
.Fields(1) = 100
.Update
.MoveNext
Loop
End With
Set cnConnection = New ADODB.Connection
cnConnection.Open strConnection
rst.UpdateBatch
End Function