VB.NET My.Settings Datatable is not saving
-
27-06-2021 - |
Question
i have a datatable that i want to save to a My.Settings Datatable However when i reopen the application i find that the table is not saved
My.Settings.Datatable = someDatatable
is there something wrong with the above statement or something else that i should do?
Solution
Assign a TableName
, for example:
If My.Settings.Datatable Is Nothing Then
My.Settings.Datatable = New DataTable
My.Settings.Datatable.TableName = "Datatable"
My.Settings.Datatable.Columns.Add("ID", GetType(Int32))
For i As Int32 = 1 To 1000
My.Settings.Datatable.Rows.Add(i)
Next
My.Settings.Save()
End If
If i reopen the application the datatable still exists.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow