Error in Record Edition

jeva39

Well-known member
Joined
Jan 28, 2005
Messages
135
Location
Panama
Programming Experience
1-3
I use this code to edit and modify a record (Sql) in my application: (I use the CommandBuilder to generate Select, Update, Insert and Delete commands)

VB.NET:
Private Sub btnActualizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnActualizar.Click
	txtBuscar.Text = ""
	Dim dtr As DataRow
	If txtTema.Text = "" Or txtTopico.Text = "" Or txtClase.Text = "" Then
	  MessageBox.Show("Tema, Topico o Clase no pueden estar en blanco", vbExclamation)
	  txtTema.Focus()
	  Exit Sub
	End If
	dtr = Me.dst.Tables("Ayuda").Rows(Me.IposAct)
	dtr("Clase") = Me.txtClase.Text
	dtr("Tema") = Me.txtTema.Text
	dtr("Topico") = Me.txtTopico.Text
	dtr("Libro") = Me.txtLibro.Text
	dtr("Capitulo") = Me.txtCapitulo.Text
	dtr("Cuaderno") = Me.txtCuaderno.Text
	dtr("Pagina") = Me.txtPagina.Text
	dtr("Info") = Me.txtInfo.Text
	dtr("Programa") = Me.txtPrograma.Text
	'dtr("ID") = Me.txtID.Text
	Try
	  Me.dta.Update(Me.dst, "Ayuda")
	Catch eUpdate As System.Exception
	  System.Windows.Forms.MessageBox.Show(eUpdate.ToString())
	End Try
	Reset()
  End Sub

The problem: When I click the Modify Button, in the database appear the original record without any modification but always create a new record with the modification. Please, can any one say me what is wrong?

Another problem: I need the correct code to delete a record.

Thanks in advanced!!
 
Back
Top