我正在尝试更新数据表并打印出更新的行,但我得到一个旧值。这是我的代码:
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”写入更新的值。