Need Help to delete records using 'recordset.Delete'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • felicia
    New Member
    • Mar 2007
    • 6

    Need Help to delete records using 'recordset.Delete'

    Hi All,

    Below is my code to delete records:

    adodcAllEntries .Recordset.Move First

    Do While (adodcAllEntrie s.Recordset.EOF = False)
    If adodcAllEntries .Recordset.Fiel ds(0) = selected_id Then
    adodcAllEntries .Recordset.Dele te
    End If

    adodcAllEntries .Recordset.Move Next
    Loop


    I encountered error when the number of records to delete is >= 4 records.

    Ther error is:
    --------------------
    Run-time error: '_2147467259 (80004005)':
    Key column information is insufficient or incorrect. Too many rows were affected by update.


    Can anyone help me to solve this?
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Is it possible that recordset had a duplicate value and it is unsure which to update?

    Good Luck.

    Comment

    • Denburt
      Recognized Expert Top Contributor
      • Mar 2007
      • 1356

      #3
      What does this recordset look like? Why can't you just run an sql statement
      "Delete * from YourTable Where selected_id = " & selected_id

      Or something to that effect.

      Comment

      • felicia
        New Member
        • Mar 2007
        • 6

        #4
        Originally posted by Denburt
        What does this recordset look like? Why can't you just run an sql statement
        "Delete * from YourTable Where selected_id = " & selected_id

        Or something to that effect.

        HI, I am very new to VB. May I know how to run that sql statement?
        i mean how to write the connection first?

        All the while i am using ADODCcontrol.re cordsource to connect to db and bind it with DataGrid control to retrieve data. This is easy for me because i no need to write the connection code.

        FYI, i am using ODBC driver to connect to db.

        Your prompt reply is very much appreciated

        Comment

        • Denburt
          Recognized Expert Top Contributor
          • Mar 2007
          • 1356

          #5
          What type of database are you using? Is it password protected? Located on a remote server?

          Comment

          Working...