Run-time error '-2147467259 (80004005)':
Could not update; currently locked.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Dim cn As New ADODB.Connection
cn.CursorLocation = adUseClient
Dim rs As New ADODB.Recordset
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
Private Sub Form_Load()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sCustomerID As String
' Open a connection to Access 2000 or Access 2002 format database.
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=<Path to Access 2000 or Access 2002 database>"
' Begin a new transaction.
cn.BeginTrans
' Specify the lock type for the table.
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
' Open a recordset for customers table.
rs.Open "SELECT * FROM CUSTOMERS", cn
rs.MoveFirst
sCustomerID = rs.Fields("CUSTOMERID").Value
rs.Fields("CITY").Value = "CLEVELAND"
rs.Update
' Close the recordset.
rs.Close
Set rs = Nothing
' Update the customers table through SQL command.
cn.Execute "UPDATE CUSTOMERS SET REGION = 'OH' WHERE customerid = '" & sCustomerID & "'"
' Close the transaction.
cn.CommitTrans
End Sub
"cn.Open "Provider=MSDASQL.1;DBQ=<path to Access 2000 or 2002 database>;Driver={Microsoft Access Driver (*.mdb)}"
Keywords: KB331594, kbnofix, kbmsg, kbdatabase, kbtsql, kbbug