i have a datagrid which show values in a dataset.
I can add new values fine with the below code, but when i delete one of the rows (highlighting a row and using the delete key) i get the error:
'Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.'
this is flaggin on the bolded line below
I can add new values fine with the below code, but when i delete one of the rows (highlighting a row and using the delete key) i get the error:
'Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.'
this is flaggin on the bolded line below
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim drNew As System.Data.DataRow
drNew = Me.ISurfDataSet.Urls.NewRow
drNew.Item("URLLink") = urlTextBox.Text
Me.ISurfDataSet.Urls.Rows.Add(drNew)
Changes = True 'set the flag to show that changes have been made
End Sub
Sub AddData() ' add the new urls to the database
Me.Validate()
Me.UrlsBindingSource.EndEdit()
Me.UrlsTableAdapter.Update(Me.ISurfDataSet.Urls)
MsgBox("All new data added successfully!")
Changes = False ' all canges have been saved so the form can close
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call AddData() ' call the function to add the new urls to the database
End Sub
Private Sub UrlsDataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles UrlsDataGridView.UserDeletedRow
Me.Validate()
Me.UrlsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.ISurfDataSet)
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim drNew As System.Data.DataRow
drNew = Me.ISurfDataSet.Urls.NewRow
drNew.Item("URLLink") = urlTextBox.Text
Me.ISurfDataSet.Urls.Rows.Add(drNew)
Changes = True 'set the flag to show that changes have been made
End Sub
Sub AddData() ' add the new urls to the database
Me.Validate()
Me.UrlsBindingSource.EndEdit()
Me.UrlsTableAdapter.Update(Me.ISurfDataSet.Urls)
MsgBox("All new data added successfully!")
Changes = False ' all canges have been saved so the form can close
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Call AddData() ' call the function to add the new urls to the database
End Sub
Private Sub UrlsDataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles UrlsDataGridView.UserDeletedRow
Me.Validate()
Me.UrlsBindingSource.EndEdit()
[B]Me.TableAdapterManager.UpdateAll(Me.ISurfDataSet)[/B]
End Sub