0

Hello! It's me again. I making a library software and I using DataBase. When I remove any record from database and then click save i got a error message: Update requires a valid DeleteCommand when passed DataRow collection with deleted rows. , and one line of code with yellow background:

Me.TableAdapterManager1.UpdateAll(Me.Database1DataSet)

I know how to fix that but i don't know what is the valid DeleteCommand in Table1TableAdapter. Table columns are: ID, FirstName, LastName, Grade, Phone, Books.

Just give me example ov valid DeleteCommand. Thanks.

3
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by LD Company
0

Look for your tableadapters. These classes contain all the commands used in your dataset to communicate with your database. If you do not see a Delete Command in the tabel adapter (in this case TableAdapterManager1), then that is why you are getting an error.

Delete FROM <Table> WHERE Id = <SomeID>

Edited by Maligui: Added code

0

Delete FROM <Table> WHERE Id = <SomeID>

Hmm.. I don't get this error anymore but when I press delete button, save, close and open program again, delete button removes all records from database. I want this button to delete only selected item, not all.

1
Delete * From <Table>;

This statement will delete all records from <Table>. Using the WHERE clause deletes the record with the ID matching the ID given.

For example:

DELETE FROM <Table> WHERE ID = ID;

Replacing <table> with your table name.

Edited by Maligui: Spelling

0

I need ID that matches with selected record. I want my delete button to remove selected record.

Edited by LD Company

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.