本文整理汇总了VB.NET中System.Data.DataRow.ItemArray属性的典型用法代码示例。如果您正苦于以下问题:VB.NET DataRow.ItemArray属性的具体用法?VB.NET DataRow.ItemArray怎么用?VB.NET DataRow.ItemArray使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Data.DataRow
的用法示例。
在下文中一共展示了DataRow.ItemArray属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CreateRowsWithItemArray
Private Sub CreateRowsWithItemArray()
' Make a DataTable using the function below.
Dim dt As DataTable = MakeTableWithAutoIncrement()
Dim relation As DataRow
' Declare the array variable.
Dim rowArray(1) As Object
' Create 10 new rows and add to DataRowCollection.
Dim i As Integer
For i = 0 to 9
rowArray(0) = DBNull.Value
rowArray(1)= "item " & i.ToString()
relation = dt.NewRow()
relation.ItemArray = rowArray
dt.Rows.Add(relation)
Next
PrintTable(dt)
End Sub
Private Function MakeTableWithAutoIncrement() As DataTable
' Make a table with one AutoIncrement column.
Dim table As New DataTable("table")
Dim idColumn As New DataColumn("id", _
Type.GetType("System.Int32"))
idColumn.AutoIncrement = True
idColumn.AutoIncrementSeed = 10
table.Columns.Add (idColumn)
Dim firstNameColumn As New DataColumn( _
"Item", Type.GetType("System.String"))
table.Columns.Add(firstNameColumn)
MakeTableWithAutoIncrement = table
End Function
Private Sub PrintTable(table As DataTable)
Dim row As DataRow
Dim column As DataColumn
For Each row in table.Rows
For Each column in table.Columns
Console.WriteLine(row(column))
Next
Next
End Sub