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
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