Is it possible for me to delete data from access using a datagrid?

Recommended Answers

All 4 Replies

Indirectly, yes. A datagrid doesnt actually contain data it only displays the data from the datasource you have attached to it. For example, if you populate a dataset, datatable, array etc and assign it to the datagrids datasource you can see the data. The user can then select a row to delete, and you delete the record from the attached datasource, not actually the dg itself.

Indirectly, yes. A datagrid doesnt actually contain data it only displays the data from the datasource you have attached to it. For example, if you populate a dataset, datatable, array etc and assign it to the datagrids datasource you can see the data. The user can then select a row to delete, and you delete the record from the attached datasource, not actually the dg itself.

Thanks!

Yes You can delete data from access
First you need to create a primary key i the table which is displayed in datagrid then.....
place a button control for delete
silply select the row to delete and press button
i am placing code for button..i am using sql server..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmdbuilder As New SqlCommandBuilder(adp1)
Dim i As Integer
Try
i = adp1.Update(ds1, "customerfeedbacknew")
MsgBox("Records Updated= " & i)
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

Yes You can delete data from access
First you need to create a primary key i the table which is displayed in datagrid then.....
place a button control for delete
silply select the row to delete and press button
i am placing code for button..i am using sql server..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmdbuilder As New SqlCommandBuilder(adp1)
Dim i As Integer
Try
i = adp1.Update(ds1, "customerfeedbacknew")
MsgBox("Records Updated= " & i)
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

I was wondering if I could put a button inside the datagrid and put the code there:-)And what if i am using OLEDB?

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.