Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002

    Unanswered: ADO + Access + Delete N Rows

    I'm having trouble trying to delete multiple rows from Access 2000 from VB 6.0 using ADO.

    Single row deletes function properly, but 2-N row deletes generate:

    Run Time Error 3219 Operation is not allowed in this context

    The code is as follows:
    ' Connect to the database & table
    With Adodc1
    .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TestData\Contact.mdb;Persist Security Info=False"
    .RecordSource = "Consultants"
    End With
    ' delete records
    With Adodc1.Recordset
    .Filter = "CurrentEmployer like 'Smith%'"
    .Delete adAffectGroup
    End With

    The error is generated on the .Delete command. I'm trying to remove records from the table and would prefer to use one command instead of writing a "For...Next" or "Do...Until" loop to remove the records.

    Any suggestions would be appreciated.
    Bruce Baasch

  2. #2
    Join Date
    Nov 2002
    San Francisco

    Re: ADO + Access + Delete N Rows

    I'm little bit lost here..... why don't you use sql DELETE * FROM Consultants WHERE CurrentEmplyer..... without touching recordset?

    Dim myConnectionString As String
    Dim myCommand As New ADODB.Command

    myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\winnt\desktop\db1.mdb;" & _
    "User Id=admin;" & _

    myCommand.ActiveConnection = myConnectionString
    myCommand.CommandText = "DELETE * FROM Consoltants WHERE ...."

    if you really want to use your DELETE, look at how you open the recordset.... cursors and locks.

    Last edited by playernovis; 01-23-03 at 21:18.

Posting Permissions

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