Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/03/2015, 02:23
piolin85
 
Fecha de Ingreso: abril-2005
Mensajes: 22
Antigüedad: 19 años
Puntos: 0
Error al Actualizar datos, utilizando combobox

Hola, aqui con este problema que tengo ahora, tengo un datagridview que carga perfectamente los datos (esta es la [URL="https://drive.google.com/file/d/0B-0oe2PnjwpCdjJjbXdtRnlvODg/view?usp=sharing"]imagen[/URL]), al presionar en una celda tengo un boton para editar dicho registro el cual me abre un formulario donde pasa todos los datos que quiero modificar (Aqui la [URL="https://drive.google.com/file/d/0B-0oe2PnjwpCR2xGOHM0cjBFMlE/view?usp=sharing"]imagen[/URL]) y tambien los carga de manera correcta

este es el metodo que utilizo para pasar los datos del datagridview al formulario para actualizar o modificar los datos

Código:
Private Sub dgvContribuyentes_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvContribuyentes.SelectionChanged
        seleccionContribuyente()
       
    End Sub
Sin embargo cuando edito tengo que dar clic en los combobox para que reconzca los id de calle, idcolonia, idmunicipio si no lo hago me marca error de update, por que detecta que la clave foranea esta vacìa o tiene un valor nulo, apesar de que paso los id

este es el [URL="https://drive.google.com/file/d/0B-0oe2PnjwpCcVF0MHVfUmNEQWM/view?usp=sharing"]error[/URL]


Código:
Function seleccionContribuyente()
        Try
            frm_EditarC_.txtIdContribuyente.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(2).Value.ToString
            frm_EditarC_.txtidDireccion.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(4).Value.ToString
            frm_EditarC_.txtNombre.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(5).Value.ToString
            frm_EditarC_.txtAP.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(6).Value.ToString
            frm_EditarC_.txtAM.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(7).Value.ToString
            frm_EditarC_.txtRazonSocial.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(8).Value.ToString
            frm_EditarC_.cboColonia.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(10).Value.ToString
            frm_EditarC_.cboMunicipio.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(11).Value.ToString
            frm_EditarC_.txttel.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(12).Value.ToString
            frm_EditarC_.txtcel.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(13).Value.ToString
            frm_EditarC_.txtemail.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(14).Value.ToString
            frm_EditarC_.cboCalle.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(15).Value.ToString
            frm_EditarC_.txtNoExterior.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(16).Value.ToString
            frm_EditarC_.cboidCalle.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(17).Value.ToString
            frm_EditarC_.cboIdCol.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(18).Value.ToString
            frm_EditarC_.cboidMupio.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(19).Value.ToString
            frm_EditarC_.cboCP.Text = dgvContribuyentes.Rows(dgvContribuyentes.CurrentRow.Index).Cells(20).Value.ToString
        Catch ex As Exception

        End Try
    End Function

el boton ya para guardar los datos es este:

Código:
Private Sub btonModificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btonInsertar.Click

        Try
            cnn.modificarContribuyente(txtIdContribuyente.Text, txtNombre.Text, txtAP.Text, txtAM.Text, txtRazonSocial.Text, txtidDireccion.Text, txttel.Text, txtcel.Text, txtemail.Text)
            MsgBox(cnn.modificarDireccion(txtidDireccion.Text, cboidCalle.SelectedItem, txtNoExterior.Text, cboIdCol.SelectedItem, cboidMupio.SelectedItem))
            cnn.MostrarContribuyentes(frm_registroC_.dgvContribuyentes)
            Me.Hide()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub
cómo hago para q al momento de pasar los datos se recarguen y no tenga esa necesesidad de dar clic en los combos, para q no me marque error de UPDATE.?