本文整理汇总了VB.NET中System.Data.DataRow类的典型用法代码示例。如果您正苦于以下问题:VB.NET DataRow类的具体用法?VB.NET DataRow怎么用?VB.NET DataRow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataRow类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: CreateNewDataRow
Private Sub CreateNewDataRow()
' Use the MakeTable function below to create a new table.
Dim table As DataTable
table = MakeNamesTable()
' Once a table has been created, use the
' NewRow to create a DataRow.
Dim row As DataRow
row = table.NewRow()
' Then add the new row to the collection.
row("fName") = "John"
row("lName") = "Smith"
table.Rows.Add(row)
Dim column As DataColumn
For Each column in table.Columns
Console.WriteLine(column.ColumnName)
Next
DataGrid1.DataSource=table
End Sub
Private Function MakeNamesTable() As DataTable
' Create a new DataTable titled 'Names.'
Dim namesTable As New DataTable("Names")
' Add three column objects to the table.
Dim idColumn As New DataColumn()
idColumn.DataType = System.Type.GetType("System.Int32")
idColumn.ColumnName = "id"
idColumn.AutoIncrement = True
namesTable.Columns.Add(idColumn)
Dim fNameColumn As New DataColumn()
fNameColumn.DataType = System.Type.GetType("System.String")
fNameColumn.ColumnName = "Fname"
fNameColumn.DefaultValue = "Fname"
namesTable.Columns.Add(fNameColumn)
Dim lNameColumn As New DataColumn()
lNameColumn.DataType = System.Type.GetType("System.String")
lNameColumn.ColumnName = "LName"
namesTable.Columns.Add(lNameColumn)
' Create an array for DataColumn objects.
Dim keys(0) As DataColumn
keys(0) = idColumn
namesTable.PrimaryKey = keys
' Return the new DataTable.
MakeNamesTable = namesTable
End Function
开发者ID:VB.NET开发者,项目名称:System.Data,代码行数:52,代码来源:DataRow
注:本文中的System.Data.DataRow类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论