NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataRow Class

Represents a row of data in a DataTable.

Object
   DataRow

[Visual Basic]
Public Class DataRow
[C#]
public class DataRow
[C++]
public __gc class DataRow
[JScript]
public class DataRow

Remarks

The DataRow, along with the DataColumn, is a primary component of a DataTable. Whereas a collection of DataColumn objects describes the schema of a table, the DataRow collection represents the actual data contained in the table. Use the DataRow class and its properties and methods to retrieve, evaluate, and manipulate the values in the table.

The overloaded Item property (DataRow indexer) returns or sets the value of any specified column.

Properties such as HasVersion and IsNull allow you to determine the status of a particular column. Additionally, the RowState property describes the state of the row in its relationship to its parent DataTable.

To create a new DataRow, use the DataTable class's NewRow method. That method uses the schema of the table, as determined by the RowsCollection, to create a new DataRow. After creating a new row, use the RowsCollection class's Add method to add the new object to the collection. Finally, call the DataTable class's AcceptChanges method to substantiate the addition.

Requirements

Namespace: System.Data

Assembly: System.Data.dll

Example [Visual Basic]

The following example creates a new DataRow through the DataTable object's NewRow method.

[Visual Basic]

Private Sub CreateNewDataRow()
   ' Use the MakeTable function below to create a new table.
   Dim myTable As DataTable
   myTable = MakeTable()
   ' Once a table has been created, use the NewRow to create a DataRow.
   Dim myRow As DataRow
   myRow = myTable.NewRow
   ' Then add the new row to the collection.
   myTable.Rows.Add(myRow)
   ' Accept Changes on the Table.
   myTable.AcceptChanges
End Sub

Private Function MakeNamesTable() As DataTable
   Dim t As DataTable
   t = New DataTable
   Dim c As DataColumn
   c = New DataColumn
   c.DataType = System.Type.GetType("System.Int32")
   c.ColumnName = "id"
   c.AutoIncrement = True
   t.Columns.Add c
   c = New DataColumn
   c.DataType = System.Type.GetType("System.String")
   c.ColumnName = "Fname"
   c.DefaultValue = "Fname"
   t.Columns.Add(c)
   c = New DataColumn
   c.DataType = System.Type.GetType("System.String")
   c.ColumnName = "LName"
   t.Columns.Add(c)
   Dim keys(0) As DataColumn
   keys(0) = t.Columns(0)
   t.PrimaryKey = keys
   ' Return Table
   MakeNamesTable = t
End Function

See Also

DataRow Members | System.Data Namespace | AcceptChanges | Add | ColumnsCollection | DataColumn | DataRowView | DataTable | HasVersion | IsNull | Item | NewRow | RowsCollection