Robert Crider Robert Crider - 3 months ago 22
Vb.net Question

Adding a new table to Xml Dataset by the click of a button in VB .Net

I am trying to find out how and if it is possible to add a new table to a dataset by letting the end user select the name and create a new table and submit it. When the user clicks submit I am planning on it adding the name to a combo box on another form and when they select it, it will show the content of that table. If anyone could give me advice it would be greatly appreciated.

Answer
Dim dataset as New DataSet
Dim table as New DataTable("tablename")
'add structure of datatable
Dim col As DataColumn
col = New DataColumn
col.ColumnName = "col1"
col.DataType = GetType(String)
table.Columns.Add(col)
col = New DataColumn
col.ColumnName = "col2"
col.DataType = GetType(String)
table.Columns.Add(col)

'add to dataset
dataset.Tables.Add(table)