I wanted to see if you can help me with the following: I have a method that updates the data of a table, it works well for me, but the issue is that I also need to update another table at the same time (the data is in common in both tables, a numeric ID), but it does not work for me to call another executequery () that would have been assigned the execution of a second query that would update the other table ...
the code of the method that I have is this
conexionMYSQL = New MySqlConnection
conexionMYSQL.ConnectionString = ("server=localhost;User Id=soporte;database=db_incidencias_muniquel;password=123")
Try
'Limpia los errores anteriores
Me.erpSoporte.Clear()
conexionMYSQL.Open()
'VALIDACION DE CONTROLES
If Me.ValidateChildren And cmbEstado.SelectedIndex <> -1 Then 'And cmbDepartamento.SelectedIndex.Equals(0)
'Dim query2 As String=("UPDATE tbl_incidencias SET id_nivel='3',id_tipo_solicitud= '5',id_categoria= '1',id_subcategoria= '2',id_registro= '1',id_registro_soporte= '4',id_metodo_ingreso= '2',id_estado= '1',fecha_registro= '2018-04-20',detalle_incidencia= " "'detalle con id de funcionario'" WHERE id_incidencia=3")
Dim query1 As String = ("UPDATE tbl_incidencias SET id_estado=@id_estado WHERE id_incidencia=@id_incidencia")
Dim query As String = ("UPDATE tbl_acciones_incidencia SET id_estado=@id_estado, comentarios_accion=@comentarios_accion WHERE id_accion=@id_accion")
comando = New MySqlCommand(query, conexionMYSQL)
comando1 = New MySqlCommand(query, conexionMYSQL)
comando.Parameters.AddWithValue("@id_estado", Convert.ToInt32(txtIdEstado.Text))
comando1.Parameters.AddWithValue("@id_estado", Convert.ToInt32(txtIdEstado.Text))
comando.Parameters.AddWithValue("@comentarios_accion", txtComentario.Text)
comando.Parameters.AddWithValue("@id_accion", Convert.ToInt32(lblIdAccion.Text))
comando1.Parameters.AddWithValue("@id_incidencia", Convert.ToInt32(lblIdIncidencia.Text))
dr = comando.ExecuteReader
dr = comando1.ExecuteReader
'MENSAJE DE CONFIRMACION
MsgBox("LA ACCIÓN CORRECTIVA A SIDO REGISTRADA E INFORMADA DE FORMA EXITOSA")
'restaurarControles()
dgvIndenciasInformadas.Refresh()
conexionMYSQL.Close()
'Me.Dispose()
Else
'FALLO LA VALIDACION DE LOS CONTROLES
MsgBox("VERIFIQUE LOS ERRORES MARCADOS EN EL FORMULARIO")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
conexionMYSQL.Dispose()
End Try
I already thank all your comments and help ...