Insertar, modificar y eliminar registros
Enviado por Emoises87 • 9 de Diciembre de 2015 • Tutorial • 770 Palabras (4 Páginas) • 220 Visitas
Public Sub nuevo_registro(ByVal cad As String)’cad es el query
conectar()
Dim comando_agregar As String
comando_agregar = cad
Dim mytrans As SqlTransaction
mytrans = Conn.BeginTransaction
Try
Dim comando = New SqlCommand(comando_agregar, Conn)
comando.Transaction = mytrans
comando.ExecuteNonQuery()
mytrans.Commit()
limpiar_controles()
Catch ex As Exception
mytrans.Rollback()
MessageBox.Show(ex.Message)
End Try
desconectar()
End Sub
Public Sub eliminar_registro(ByVal cad As String)
Dim sql As String
sql = cad
conectar()
Dim mytrans As SqlTransaction
mytrans = Conn.BeginTransaction()
Try
Dim comando = New SqlCommand(sql, Conn)
comando.Transaction = mytrans
comando.ExecuteNonQuery()
mytrans.Commit()
Catch ex As Exception
mytrans.Rollback()
MessageBox.Show(ex.Message)
End Try
desconectar()
End Sub
Public Sub actualizar(ByVal cad As String, ByVal form As String)
Dim consulta_combo As String
consulta_combo = cad
conectar()
Dim da As New SqlDataAdapter(consulta_combo, Conn)
Dim ds As New DataSet
da.Fill(ds, form)
desconectar()
End Sub
Public Sub modificar(ByVal cad As String)
Dim sql As String
sql = cad
conectar()
Dim mytrans As SqlTransaction
mytrans = Conn.BeginTransaction()
...