Datagrid Delete Problem

G

Guest

I have a webform in VB.NET that
contains a Datagrid control.
My datagrid has buttons for updates
and deletes.
The updates work fine, but the deletes
are not being updated in the DB for
some reason. I see the changes
in the datagrid, but when I restart
the app., the row is back.

Here is all the info you might need:

Components:

- Access DB
- OleDBDataAdapter1
- OleDBConnection1
- Dataset1
- grdData

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

OleDbDataAdapter1.Fill(DataSet1)

If Not IsPostBack Then
grdData.DataBind()
End If

End Sub

Private Sub grdData_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
grdData.DeleteCommand

Dim key As String = grdData.DataKeys(e.Item.ItemIndex).ToString()

Dim r As DataSet1.PeopleRow
r = DataSet1.People.FindByName(key)

r.Delete()
DataSet1.AcceptChanges()
OleDbDataAdapter1.Update(DataSet1)

grdData.DataBind()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top