Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Unanswered: ADO Connection error

    I'm new to ADO My task is to read a recordset in from one table go through some logical construct then write new records to a another table
    but I can't get past this "the database has been placed ina state by user 'admin' on machine 'oemcomputer' that prevents it from being opened or locked error." I am running this code on the click event of a command button

    Dim currCON As New ADODB.Connection
    currCON.Open CurrentProject.Connection


    The error occurs on the second line
    Sorry if this is a dumb question

  2. #2
    Join Date
    Oct 2003
    Location
    India
    Posts
    55

    Chekc for read only status

    Hi

    Just just check wether the mdb file is in read only status.

    just a doubt

    regards
    Sree

  3. #3
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    I have found ADO to be flaky like this as well. If I save before executing it will sometimes work, but if the code hasn't had a chance to compile and save, the db goes into a state that (I guess) stops other users from coming in (including you, again) and preventing you save efforts.

    -- I'm making some assumptions about what you are trying to do --

    You don't really need to create a connection object for the currentproject when working with recordsets. You can use
    rst.open SQL, currentproject.connection
    All code ADO/ADOX unless otherwise specified.
    Mike.

  4. #4
    Join Date
    Dec 2003
    Posts
    3
    Thank you all for the help
    sreeraj The file was not read only.
    The current task I am trying to perform is to delete all the records in a recordset and it does work if I have used
    Dim currCON As New ADODB.Connection
    currCON.Open CurrentProject.Connection
    But I was only able to delete one record at a time with somethong like this

    Dim strSQL As String
    Dim Rst As ADODB.Recordset
    strSQL = "SELECT * FROM MAKINOTABLE ;"
    Set Rst = New ADODB.Recordset
    Rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

    If Not Rst.EOF Then
    With Rst
    .Delete
    End With
    End If
    Iv'e read that you need to use the connnection object to execute a query
    and what I was trying to do was execute a delete action query

    Thanks Cheers

  5. #5
    Join Date
    Dec 2003
    Posts
    3
    HomerBoo

    Saving and reopening the form eliminates that error give things a chance to compile as you said

    Thanks

  6. #6
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Dennis88:

    Now that I see what you're trying to do, I can reduce your code to one line:

    CurrentProject.Connection.Execute "DELETE * FROM MAKINOTABLE;"

    Your method is most useful if you want to evaluate the records to something else before you delete them. Evaluating them to themselves would use a WHERE clause in the above.
    All code ADO/ADOX unless otherwise specified.
    Mike.

Posting Permissions

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