How to delete record from dataset?
I have customer/order form.When i delete a record from datagrid.It deletes the record but when i refresh the page or run the app again it comes because i think it just deletes temp from the grid not from the database.How do delete it from the database?
Code:
Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
'Me.CustomerTableAdapter.Fill(Me.CustomerDataSet.Customer)
'BindingSource1.Remove(CustomerDataSet.Customer)
BindingSource1.RemoveCurrent()
End Sub
Re: How to delete record from dataset?
What is your data source?
Re: How to delete record from dataset?
ADO.NET works in a disconnected state by default. So when you delete from the datatable, it is only removed from the datatable. To delete from the database, you will need to issue a proper DELETE SQL command one way or another. One would be to use the Table/DataAdaptor, setting the Delete command and using the .Update method to commit the changes to the database.
The other way is to do it yourself, create a command object, setting the command text property and executing it.
-tg