本文整理匯總了VB.NET中System.Data.DataTable.Rows屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET DataTable.Rows屬性的具體用法?VB.NET DataTable.Rows怎麽用?VB.NET DataTable.Rows使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.Rows屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: PrintRows
Private Sub PrintRows(dataSet As DataSet)
' For each table in the DataSet, print the values of each row.
Dim thisTable As DataTable
For Each thisTable In dataSet.Tables
' For each row, print the values of each column.
Dim row As DataRow
For Each row In thisTable.Rows
Dim column As DataColumn
For Each column In thisTable.Columns
Console.WriteLine(row(column))
Next column
Next row
Next thisTable
End Sub
Private Sub AddARow(dataSet As DataSet)
Dim table As DataTable = dataSet.Tables("Suppliers")
' Use the NewRow method to create a DataRow
'with the table's schema.
Dim newRow As DataRow = table.NewRow()
' Set values in the columns:
newRow("CompanyID") = "NewCompanyID"
newRow("CompanyName") = "NewCompanyName"
' Add the row to the rows collection.
table.Rows.Add(newRow)
End Sub
示例2: MainClass
' 導入命名空間
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Windows.Forms
Imports System.Resources
Public Class MainClass
Shared Sub Main()
Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Employee.mdb;"
Dim objConnection As New OleDbConnection(strConnectionString)
Dim strSQL As String = "SELECT FirstName, LastName FROM Employee"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
Dim objDataAdapter As New OleDbDataAdapter(objCommand)
Dim objDataTable As New Data.DataTable("Employee")
Dim objDataRow As DataRow
Try
objConnection.Open()
objDataAdapter.Fill(objDataTable)
For Each objDataRow In objDataTable.Rows
Console.WriteLine(objDataRow.Item("FirstName") & " " & objDataRow.Item("LastName"))
Next
Catch OleDbExceptionErr As OleDbException
Console.WriteLine(OleDbExceptionErr.Message)
Catch InvalidOperationExceptionErr As InvalidOperationException
Console.WriteLine(InvalidOperationExceptionErr.Message)
End Try
objConnection.Close()
objDataRow = Nothing
objDataTable.Dispose()
objDataTable = Nothing
objDataAdapter.Dispose()
objDataAdapter = Nothing
objCommand.Dispose()
objCommand = Nothing
objConnection.Dispose()
objConnection = Nothing
End Sub
End Class