Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/11/2005, 13:46
RugalMKing
 
Fecha de Ingreso: octubre-2004
Mensajes: 55
Antigüedad: 19 años, 7 meses
Puntos: 0
Pregunta Problema actualizando XML.

Espero me puedan ayudar,

Tengo una aplicacion en .Net que administra contactos telefonicos. Al presionar el boton Actualizar, para aplicar los cambios hechos a un contacto me aparece el error:

Object reference not set to an instance of an object.

Este es el codigo del evento:

Código:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        'Try
            'Send updates to xml file
        Dim xDoc As XmlDocument = New XmlDocument()
        Dim root, id As XmlNode
        Dim i As Integer
        root = xDoc.DocumentElement

        For i = 0 To root.ChildNodes.Count - 1 'AQUI ME SEÑALA EL ERROR
            id = root.ChildNodes(i).Attributes("CustomerID")
            If (id.InnerText = txtUniqueID.Text) Then
                xDoc.DocumentElement("CustomerID").Value = txtUniqueID.Text
                xDoc.DocumentElement("CompanyName").Value = txtCoName.Text
                xDoc.DocumentElement("ContactName").Value = txtContact.Text
                xDoc.DocumentElement("ContactTitle").Value = txtTitle.Text
                xDoc.DocumentElement("Address1").Value = txtAddress.Text
                xDoc.DocumentElement("Phone1").Value = txtPhone1.Text
                xDoc.DocumentElement("Phone2").Value = txtPhone2.Text
            End If
        Next i
        xDoc.Save(m_connCustomers)

        'Reset and begin again
        LoadDataSet()
        MsgBox("Record has been updated.")
        'Attempt to update the datasource.
        Me.LoadDataSet()
        'Catch eUpdate As System.Exception
        '    'Add your error handling code here.
        '    'Display error message, if any.
        '    System.Windows.Forms.MessageBox.Show(eUpdate.Message)
        'End Try
        Me.dsCust_PositionChanged()

    End Sub
Gracias por su ayuda.