How to delete a record

jeva39

Well-known member
Joined
Jan 28, 2005
Messages
135
Location
Panama
Programming Experience
1-3
Please, I need the correct code to delete a record in a Sql Database. I use this, don´t give an error but neither delete the record

VB.NET:
Private Sub btnBorrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBorrar.Click
	Try
	  Dim dtr As DataRow
	  dtr = Me.dst.Tables("Ayuda").Rows(Me.ActualPosition)
	  dtr.Delete() ' delete row
	 ' Use a Temp Table 	 
	 Dim oTablaBorrados As DataTable
	  oTablaBorrados = Me.dst.Tables("Ayuda").GetChanges(DataRowState.Deleted)
	  Me.dta.Update(oTablaBorrados)
	  Me.dst.Tables("Ayuda").AcceptChanges()
	  Me.btnpri.PerformClick() ' Go to the first record
	Catch eUpdate As System.Exception
	  System.Windows.Forms.MessageBox.Show(eUpdate.ToString())
	End Try
End Sub
 
Back
Top