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.

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>

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.

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.

Unless ID = %. This will delete all records because % matches any value.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.