I have a DataTable read from a csv file:
ID,ItemCode,ItemDescription
1,Test0,test item
2,Test2,second test item
When I try to create an additional column as in https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/dataset-datatable-dataview/adding-columns-to-a-datatable, it silently fails. The code:
dataTable.TableName = "test"
dataTable.Columns.Add("MyTestColumn", GetType(String))
dataTable.AcceptChanges()
Using sw As StringWriter = New StringWriter()
dataTable.WriteXml(sw)
Console.WriteLine(sw)
End Using
has output
<DocumentElement>
<test>
<Column1>ID</Column1>
<Column2>ItemCode</Column2>
<Column3>ItemDescription</Column3>
</test>
<test>
<Column1>1</Column1>
<Column2>Test0</Column2>
<Column3>test item</Column3>
</test>
<test>
<Column1>2</Column1>
<Column2>Test2</Column2>
<Column3>second test item</Column3>
</test>
</DocumentElement>
Is it possible to add a column in this way?