Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recordset locking problem (run-time error)

Status
Not open for further replies.

spiralmind

Technical User
Aug 20, 2002
130
US
How do I prevent this from happening:

Run-time error '-2147467259(80004005)':

The database has been placed in a state by user 'Admin' on machine
'LIBERTY-0D10453' that prevents it from being opened or locked.

Here's the code that generates this error:

'///////////////////////////////////////////////////////////

Function varDataArray(strTable As String) As Variant

' Create an ADO connection:

Dim ctn As New ADODB.Connection
Set ctn = New ADODB.Connection
ctn.Provider = "Microsoft.Jet.OLEDB.4.0"
ctn.ConnectionString = "Data Source= " & CurrentDb.Name
{b]ctn.Open[/b]

' Create an ADO recordset:

Dim rst As New ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorType = adOpenForwardOnly
rst.LockType = adLockOptimistic
rst.Open strTable, ctn

' Create an array from the data stored in the specified table:

varDataArray = rst.GetRows

' Close the recordset:

rst.Close
ctn.Close

End Function

'///////////////////////////////////////////////////////////

My code sporadicly freezes on the "ctn.open" line, and appears to the user to be doing nothing (not frozen - just doing nothing), and generates above error message when I run it in debug mode. Sometimes this occurs on even the first time I try to open the recordset (which is in all cases either a valid table name or SQL string, and which does at times work exactly as it should), so I don't think I just have a problem with unlocking it. Furthermore, I'm not 'Admin', the computer has an 'Admin' account, but that's only for system repairs and non-standard software installations (neither of which are things I've recently undergone), so it seems windows itself has a problem with something I'm trying to do. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top