Update

13/07/2006 - 15:56 por JReyes | Informe spam
Como puedo darme cuenta si se hizo algun cambio el base de datos al ejecutar
este codigo:

AbrirConexion()
Dim cActualizar As OleDbCommand
cActualizar = New OleDbCommand("UPDATE AM_Medicamentos SET " & _
"Medicamentos = @Nombre," & _
"Presentacion_Medicamentos = @Presentacion," & _
"Descripcion_Medicamentos = @Descripcion," & _
"WHERE ID_Medicamentos = @ID", oSQLConn)

cActualizar.Parameters.Add("@Nombre", OleDbType.VarChar, 50).Value =
txtNombre.Text
cActualizar.Parameters.Add("@Presentacion", OleDbType.VarChar, 255).Value =
txtPresentacion.Text
cActualizar.Parameters.Add("@Descripcion", OleDbType.VarChar, 50).Value =
txtDescripcion.Text
cActualizar.Parameters.Add("@ID", OleDbType.Numeric, 10).Value =
txtCodigo.Text
Try
cActualizar.ExecuteNonQuery()
MsgBox("Información actualizada correctamente...", MsgBoxStyle.Information _
Or MsgBoxStyle.SystemModal _
Or MsgBoxStyle.MsgBoxRight _
Or MsgBoxStyle.MsgBoxRtlReading, "Info. Consultorio")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical _
Or MsgBoxStyle.MsgBoxRight _
Or MsgBoxStyle.MsgBoxRtlReading)
End Try
 

Leer las respuestas

#1 Eduardo A. Morcillo [MS MVP VB]
13/07/2006 - 16:45 | Informe spam
ExecuteNonQuery te devuelve la cantidad de registros afectadas por el
comando ejecutado. Si todo esta bien en la consulta pero no modifica nada te
devuelve 0, y por supuesto que si hay algun otro problema se generara una
excepcion.

Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
http://mvp.support.microsoft.com/pr...4EF5A4191C

Preguntas similares