Error al borrar registro...
Publicado por zunea (18 intervenciones) el 17/02/2012 20:17:33
Amigos, muchas gracias de antemano;
Tengo el siguiente codigo para borrar y si que lo hace...
El problema es que borrar el primer registro y no tiene en cuenta el codigo del texbox.codigo...
Es decir, me paro en el registro 3 y borra el registro 1.
Si estoy en el registro 4, borra el 1....
Le agradezco si me ayudan....
Gracias
If MsgBox("seguro de eliminar registro?", MsgBoxStyle.OkCancel) Then
Dim cn As New SqlConnection
Dim query As New SqlCommand
Dim res As Integer
cn.ConnectionString = SDSEmpleados.ConnectionString
cn.Open()
query.CommandType = Data.CommandType.Text
query.CommandText = "Delete from Empleados where id ='" & Me.TextBoxCod.Text & "'"
query.Connection = cn
res = query.ExecuteNonQuery
If res <> 0 Then
MsgBox("Registro Eliminado", MsgBoxStyle.Information, "Student Manager")
End If
cn.Close()
Me.iPosicFilActual = 0
Me.cargardatos()
Else
Exit Sub
End If
Tengo el siguiente codigo para borrar y si que lo hace...
El problema es que borrar el primer registro y no tiene en cuenta el codigo del texbox.codigo...
Es decir, me paro en el registro 3 y borra el registro 1.
Si estoy en el registro 4, borra el 1....
Le agradezco si me ayudan....
Gracias
If MsgBox("seguro de eliminar registro?", MsgBoxStyle.OkCancel) Then
Dim cn As New SqlConnection
Dim query As New SqlCommand
Dim res As Integer
cn.ConnectionString = SDSEmpleados.ConnectionString
cn.Open()
query.CommandType = Data.CommandType.Text
query.CommandText = "Delete from Empleados where id ='" & Me.TextBoxCod.Text & "'"
query.Connection = cn
res = query.ExecuteNonQuery
If res <> 0 Then
MsgBox("Registro Eliminado", MsgBoxStyle.Information, "Student Manager")
End If
cn.Close()
Me.iPosicFilActual = 0
Me.cargardatos()
Else
Exit Sub
End If
Valora esta pregunta


0