In the first statements, we create a DataTable and adds 3 columns to it. Internally the DataTable creates DataColumn instances—but we do not see them here.
Module Module1
Sub Main()
' Create DataTable and add columns.
Dim table As DataTable = New DataTable()
table.Columns.Add(
"Dosage", GetType(Integer))
table.Columns.Add(
"Medication", GetType(String))
table.Columns.Add(
"Patient", GetType(String))
' Add a column object in a different way.
Dim column As DataColumn = New DataColumn(
"Appointment", GetType(DateTime))
table.Columns.Add(column)
' Add some rows.
table.Rows.Add(32,
"Combivent",
"Jane", DateTime.Now)
table.Rows.Add(100,
"Dilantin",
"Mark", DateTime.Now)
' Loop over columns.
For Each c As DataColumn In table.Columns
Console.WriteLine(
"{0} = {1}", c, c.DataType)
Next
End Sub
End Module
Dosage = System.Int32
Medication = System.String
Patient = System.String
Appointment = System.DateTime