Hi All,

I have created a form called new users, I have added my data source, draged over the objects I want from the dataset onto the form and all is well appart from the fact that I cant delete records.

To add them I simply click the add button, put in my info and then click the little disk button to update the dataset.

This does not work for the delete button though, instead I get the following error

UPDATE REQUIRES A VALID DELETE COMMAND WHEN PASSED DATA ROW COLLECTION WITH DELETED ROWS.

This is the code for my form.

Public Class NewUsers

    Private Sub UsersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.UsersBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.MtrmanagerDataSet)

    End Sub

    Private Sub NewUsers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MtrmanagerDataSet.Users' table. You can move, or remove it, as needed.
        Me.UsersTableAdapter.Fill(Me.MtrmanagerDataSet.Users)

    End Sub
End Class

Can anyone give me a guide as to what code I need to use so I can delete recods and then update or save the current data.

Thanks very much.

John

Recommended Answers

All 2 Replies

You can follow this link: (it is for MSAccess, but will let you know how to do that)
Instead of OLEDB Classes you can use SqlClient's Classes like:
SqlConnection
SqlCommand
SqlDataREader
etc.....
http://www.codeproject.com/KB/vb/InsertUpdateDeleteSearch.aspx

Cheers for that Shahan, it seems to me that its easier to hard code objects like update, delete and stuff like that rather than dragging the dataset from the wizard.

Thanks again for that.

John

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.