locked
first xml file... RRS feed

  • Question

  • i have the following code:
        Private Sub UpdateDisplay()
    CurrentContact = DirectCast(Me.cmbKlant.DataSource, ContactCollection)(Me.cmbKlant.SelectedIndex)
    Dim xDoc As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\data\computer.xml"
    If FileExists(xDoc) Then
    DataSet1.ReadXml(xDoc)
    DataSet1.Tables("PC").Select("AccountName = " & currentContact.AccountName)
    If DataSet1.Tables("PC").Rows.Count <> 0 Then
    lblComputerCount.Text = DataSet1.Tables("PC").Rows.Count
    Else
    lblComputerCount.Text = "0"
    End If
    Else
    lblComputerCount.Text = "0"
    End If
    If currentContact.MobileTelephoneNumber <> "" Then
    Me.lblTelefoonnummerDisplay.Text = currentContact.MobileTelephoneNumber
    ElseIf currentContact.HomeTelephoneNumber <> "" Then
    Me.lblTelefoonnummerDisplay.Text = currentContact.HomeTelephoneNumber
    Else
    Me.lblTelefoonnummerDisplay.Text = currentContact.BusinessTelephoneNumber
    End If
    End Sub
    With this code, i try to find out how many computers are assigned to a single contact. the computers are going to be stored in an xml-file. The problem i have is what do i do with the very first time the program is running when the xml file doesn't exist yet. As you can see in the code, i have my xml-file loading in a already structured dataset to make it a lot easy-er to manipulate the data. Do i just go on as i do now and at closing time off the app (or the add computer form) save the xml-file or is there something else i need to do first.
    Wednesday, April 1, 2009 12:31 AM

Answers

  • Hi eagle00789,

    As far as I know, the proper way is: 
    1. Check whether the document exists, you have done it.
    2. If it doesn't exist, save some xml data to the xml at closing time. But it depend on your requirement.


    Best regards,
    Guang-Ming Bian - MSFT


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, April 3, 2009 3:08 AM

All replies

  • anybody??
    Thursday, April 2, 2009 8:08 PM
  • Hi eagle00789,

    As far as I know, the proper way is: 
    1. Check whether the document exists, you have done it.
    2. If it doesn't exist, save some xml data to the xml at closing time. But it depend on your requirement.


    Best regards,
    Guang-Ming Bian - MSFT


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Friday, April 3, 2009 3:08 AM