Question about Access & Excel

O

omsoft

I have the following function in Excel app which uses Access as back-end.
Here it reads a table in back-end and retrieves an boolean to determine which
code path to follow. Every once in a while, I get an error that the <machine
name> has put the data base in admin state. The line it points to
conn.open(strConn) line in the function.

Does anyone have any thoughts on what this could be?
Thanks.

Public Function getCodePath()

Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConn, strDB, strSQL As String

strSQL = "SELECT * FROM tmp_fromOscar"
strDB = OSCAR_DIR & OSCAR_DATA
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strDB & ";"

Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open (strConn)
conn.CursorLocation = adUseClient
rs.Open strSQL, conn, adOpenStatic, adLockReadOnly

If rs.RecordCount > 0 Then
rs.MoveFirst
bFrom = rs("fromO").Value
End If

rs.Close
conn.Close

Set rs = Nothing
Set conn = Nothing
getCodePath = bFrom
End Function
 
J

JP

The only thing I can think of is that someone (or someTHING) else has
the database open and locked.

--JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top