更新数据表并显示新值

时间:2018-03-26 11:20:36

标签: vb.net

我正在尝试更新数据表并打印出更新的行,但我得到一个旧值。这是我的代码:

   Public Shared zadnjiBrojevi As DataTable
...

    aaaa.ItemsSource = Globals.zadnjiBrojevi
    Dim lastnr As Integer
    Dim result() As DataRow = Globals.zadnjiBrojevi.Select("tip = " & tipoviDokumenataCbox.SelectedItem.tag & "")
    For Each row As DataRow In result
        lastnr = row(1)
    Next
    Console.WriteLine("Last number is: " & lastnr)

    Dim myRow() As Data.DataRow
    myRow = Globals.zadnjiBrojevi.Select("tip = '" & tipoviDokumenataCbox.SelectedItem.tag & "'")
    myRow(0)("lastnr") = myRow(0)("lastnr") + 1

    Dim filename As String = Globals.rootPath & "ZadnjiBrojevi.xml"
    Globals.zadnjiBrojevi.WriteXml(filename, XmlWriteMode.WriteSchema)
    Console.WriteLine("Dodan upis!")

在控制台中,我总是得到“最后的号码是:4443”。但GridControl“aaaa”显示更新的值。并且“writexml”写入更新的值。

0 个答案:

没有答案