By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,855 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,855 IT Pros & Developers. It's quick & easy.

Need Help to delete records using 'recordset.Delete'

P: 6
Hi All,

Below is my code to delete records:

adodcAllEntries.Recordset.MoveFirst

Do While (adodcAllEntries.Recordset.EOF = False)
If adodcAllEntries.Recordset.Fields(0) = selected_id Then
adodcAllEntries.Recordset.Delete
End If

adodcAllEntries.Recordset.MoveNext
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?
Apr 1 '07 #1
Share this Question
Share on Google+
4 Replies


iburyak
Expert 100+
P: 1,017
Is it possible that recordset had a duplicate value and it is unsure which to update?

Good Luck.
Apr 1 '07 #2

Denburt
Expert 100+
P: 1,356
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.
Apr 1 '07 #3

P: 6
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.recordsource 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
Apr 2 '07 #4

Denburt
Expert 100+
P: 1,356
What type of database are you using? Is it password protected? Located on a remote server?
Apr 2 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.