S
Siegfried Heintze
I have a datagrid bound to a dataview which is connected to a dataset which
is bound to MSAccess.
The following code deletes a record, but not the one for which I click the
delete link. I think this is because the data rows are in a different order
because of the data view. I think I have to translate the row number I'm
receiving. How do I do this?
Incidently, is there an easier way to delete a record? I was hoping there
was a simple function I could call in the dataset instead of having to
populate the parameters of a stored procedure or prepared statement.
Thanks,
Siegfried
Private Sub dgAssertions_DeleteCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles dgAssertions.DeleteCommand
Dim index As Integer
index = e.Item.ItemIndex
rebind()
' Add code to delete data from data source.
Dim dr As dsAssertions.AssertionsRow =
DsAssertions1.Assertions.Rows(index)
'DsAssertions1.Assertions.Rows.RemoveAt(index)
daAssertions.DeleteCommand.Parameters(0).Value = dr.nAssertion
daAssertions.DeleteCommand.Parameters(1).Value = dr.ridCase
daAssertions.DeleteCommand.Parameters(2).Value = dr.A
daAssertions.DeleteCommand.Parameters(3).Value = dr.A
daAssertions.DeleteCommand.Parameters(4).Value = dr.B
daAssertions.DeleteCommand.Parameters(5).Value = dr.B
daAssertions.DeleteCommand.Parameters(6).Value = dr.C
daAssertions.DeleteCommand.Parameters(7).Value = dr.C
daAssertions.DeleteCommand.Parameters(8).Value = dr.D
daAssertions.DeleteCommand.Parameters(9).Value = dr.D
daAssertions.DeleteCommand.Parameters(10).Value = dr.E
daAssertions.DeleteCommand.Parameters(11).Value = dr.E
daAssertions.DeleteCommand.Connection.Open()
daAssertions.DeleteCommand.ExecuteScalar()
rebind()
End Sub
is bound to MSAccess.
The following code deletes a record, but not the one for which I click the
delete link. I think this is because the data rows are in a different order
because of the data view. I think I have to translate the row number I'm
receiving. How do I do this?
Incidently, is there an easier way to delete a record? I was hoping there
was a simple function I could call in the dataset instead of having to
populate the parameters of a stored procedure or prepared statement.
Thanks,
Siegfried
Private Sub dgAssertions_DeleteCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles dgAssertions.DeleteCommand
Dim index As Integer
index = e.Item.ItemIndex
rebind()
' Add code to delete data from data source.
Dim dr As dsAssertions.AssertionsRow =
DsAssertions1.Assertions.Rows(index)
'DsAssertions1.Assertions.Rows.RemoveAt(index)
daAssertions.DeleteCommand.Parameters(0).Value = dr.nAssertion
daAssertions.DeleteCommand.Parameters(1).Value = dr.ridCase
daAssertions.DeleteCommand.Parameters(2).Value = dr.A
daAssertions.DeleteCommand.Parameters(3).Value = dr.A
daAssertions.DeleteCommand.Parameters(4).Value = dr.B
daAssertions.DeleteCommand.Parameters(5).Value = dr.B
daAssertions.DeleteCommand.Parameters(6).Value = dr.C
daAssertions.DeleteCommand.Parameters(7).Value = dr.C
daAssertions.DeleteCommand.Parameters(8).Value = dr.D
daAssertions.DeleteCommand.Parameters(9).Value = dr.D
daAssertions.DeleteCommand.Parameters(10).Value = dr.E
daAssertions.DeleteCommand.Parameters(11).Value = dr.E
daAssertions.DeleteCommand.Connection.Open()
daAssertions.DeleteCommand.ExecuteScalar()
rebind()
End Sub