asp_databases thread: ODBC Drivers error 80004005: Could not update; currently locked by...
The following chunk of code from an ad rotator I'm writing is throwing the
error mentioned in the subject line of this message when it reaches the
"Ad_Serve.Update" line, but only under certain circumstances.
The database is MS Access.
Here's the code (extracted from a subroutine called Show_Ad(Position_In))
that randomly picks an ad to serve in the specified ad position:
-------------------------------
Set dbContent = Server.CreateObject("ADODB.Connection")
dbContent.Open "Driver={Microsoft Access Driver (*.mdb)}; Dbq=" &
Server.MapPath("/fpdb/content.mdb") & ";"
SQL = "SELECT Ad_ID, Image_Source, Image_Width, Image_Height,
Impression_Count "
SQL = SQL & "From Ad WHERE Ad_Position_ID = " & Position_In & " "
SQL = SQL & "AND Weight_Low <= " & Random_Number & " AND " & Random_Number &
" <= Weight_High; "
Set Ad_Serve = Server.CreateObject("ADODB.Recordset")
Ad_Serve.Open SQL, dbContent, adOpenDynamic, adLockOptimistic, adCmdText
' Serve the ad
Response.Write "<a href=""/ad_click_thru.asp?ad=" & Ad_Serve.Fields("Ad_ID")
& """><img src=""" & Ad_Serve.Fields("Image_Source") & """ border=""0""
width=""" & Ad_Serve.Fields("Image_Width") & """ height=""" &
Ad_Serve.Fields("Image_Height") & """></a>"
' Increment that ad's impression count
Impr_Count = Ad_Serve.Fields("Impression_Count")
Ad_Serve.Fields("Impression_Count") = Impr_Count + 1
Ad_Serve.Update
Ad_Serve.Close
Set Ad_Serve = Nothing
-------------------------------
Here's the circumstances:
1) Runs perfectly under all circumstances on my local PWS server.
2) Runs perfectly on my Web host as long as you just serve one ad on a page
3) If you serve an ad to each of two ad positions by calling Show_Ad twice,
the first call works perfectly. The second call gets to the
"Ad_Serve.Update" line (line 47) and crashes with this error message:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Could not update; currently locked
by user 'admin' on machine 'PROSERVER1104'.
/include/lib_ad_serve.asp, line 47
I've created a test harness you can use to serve an ad to position 1, or
serve an ad to position 2, or serve ads to positions 1 and 2. All three
options work perfectly on my local PWS server. The first two options work
perfectly on my Web host, even if you run them repeatedly. The third option
always crashes on my Web host, as explained above.
I'm stumped! Any ideas?
Thanks very much,
Charlie Darling