Results 1 to 3 of 3

Thread: Accessing Data from an Access Database on CD-ROM

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Location
    Snellville, GA, USA
    Posts
    38

    Question

    Can anyone tell me if its possible to write code to access data from an access database that is burned onto a CD-ROM? I keep getting the following error when I try. Do I need to change my cursor location or locktype in my ado code?

    Error:
    The Microsoft Jet database engine cannot open the file 'E:\alprgama.mdb'. It is already opened exclusively by another user, or you need permission to view its data.

    Code:
    Private Sub Form_Load()
    Dim rst As adodb.Recordset
    Set rst = CreateObject("adodb.recordset")
    rst.LockType = adLockReadOnly
    rst.CursorLocation = adUseServer
    rst.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=E:\alprgama.mdb"
    rst.Open "select * from equipment"
    While Not rst.EOF
    List1.AddItem rst!equipid
    rst.MoveNext
    Wend
    End Sub

    -Elias

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    example of reading a read-only MDB file:

    Code:
        Dim cn As New Connection
        Dim rs As New Recordset
        
        
        
        cn.Mode = adModeRead
        cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=Nwind.mdb"
        
        
        rs.Open "Select * from Customers", cn
        
        MsgBox rs(1)
    you might have to explicitly create a connection object for your RS

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 1999
    Location
    Snellville, GA, USA
    Posts
    38
    Actually, that didn't work, but the following did! Thanks for the help.

    Private Sub Form_Load()
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim errX As ADODB.Error
    'On Error Resume Next
    On Error GoTo FormError
    cn.Mode = adModeShareDenyWrite ' ******* This mode is what you need to make it work for a db burned on cd *******

    cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=E:\alprgama.mdb"

    rs.Open "Select * from equipment", cn
    'If Len(rs!equipid) = 0 Then
    While Not rs.EOF
    List1.AddItem rs!equipid
    rs.MoveNext
    Wend
    'End If
    Exit Sub
    FormError:
    For Each errX In cn.Errors
    MsgBox errX.Description
    Next errX

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width