| | |
detecting delete on row in datagridview and updating dataset
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 114
Reputation:
Solved Threads: 6
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
any help is appreciated
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
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 Subany help is appreciated
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: button background colour on mouse enter event
- Next Thread: AttachEventHandler issues
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dropdownlist excel fade file-dialog folder ftp generatetags google hardcopy image images input insert intel internet login mobile monitor ms net networking objects opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port problem problemwithinstallation project reports" save savedialog searchvb.net select serial shutdown soap string survey tcp temperature text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





