DekGenius.com
[ Team LiB ] Previous Section Next Section

DataRow serializable

System.Data (system.data.dll) class

The DataRow class represents a single record in a database. You can access the columns of the record using the indexer, which is also the indexer for the class. You can retrieve or set a column value using a zero-based index or the column name. Using the name is slightly slower because it requires a behind-the-scenes hashtable lookup. The indexer has two overloads that allow you to specify the row version to retrieve using the DataRowVersion enumeration. For example:

Console.Write(row["ID"], DataRowVersion.Original); 

retrieves the original data source value, even if it has been modified. If you omit the version, you receive the current (DataRowVersion.Current ) value.

Alternatively, you can get or set values for all the rows at one time using the ItemArray property. The ItemArray is a one-dimensional array, in which each item contains the value for a field, in the same order as the DataRow . The ItemArray doesn't include the names of the field. You can also retrieve the state of the row (indicating if it has been added, deleted, and so on), using the RowState property.

The DataRow allocates space for error information. You can set or retrieve a string that describes an error using the SetColumnError( ) or GetColumnError( ) methods. To determine if the row has any errors, simply inspect the Boolean HasErrors property or retrieve the DataColumn objects with errors using the GetColumnsInError( ) method.

The GetParentRow( ) and GetChildRows( ) methods allow you to retrieve related rows if you have defined a parent-child relationship using a DataRelation object.

The DataRow also includes methods for managing the editing process, including BeginEdit( ) , EndEdit( ) , and CancelEdit( ) . BeginEdit( ) suspends row validation until either EndEdit( ) or CancelEdit( ) is called, allowing the rows to temporarily violate referential integrity.

public class DataRow {
// Protected Constructors
   protected internal DataRow( DataRowBuilder builder);  
// Public Instance Properties
   public bool HasErrors{get; } 
   public object[ ] ItemArray{set; get; } 
   public string RowError{set; get; } 
   public DataRowState RowState{get; } 
   public DataTable Table{get; } 
   public object this[string columnName, DataRowVersion version]{get; } 
   public object this[DatraColumn column, DataRowVersion version]{get; } 
   public object this[string columnName]{set; get; } 
   public object this[int columnIndex]{set; get; } 
   public object this[int columnIndex, DataRowVersion version]{get; } 
   public object this[DataColumn column]{set; get; } 
// Public Instance Methods
   public void AcceptChanges(  );  
   public void BeginEdit(  );  
   public void CancelEdit(  );  
   public void ClearErrors(  );  
   public void Delete(  );  
   public void EndEdit(  );  
   public DataRow[ ] GetChildRows( DataRelation relation);  
   public DataRow[ ] GetChildRows(DataRelation relation, DataRowVersion version);
   public DataRow[ ] GetChildRows( string relationName);  
   public DataRow[ ] GetChildRows(string relationName,  DataRowVersion version);
   public string GetColumnError( DataColumn column);  
   public string GetColumnError( int columnIndex);  
   public string GetColumnError( string columnName);  
   public DataColumn[ ] GetColumnsInError(  );  
   public DataRow GetParentRow( DataRelation relation);  
   public DataRow GetParentRow(DataRelation relation, DataRowVersion version);
   public DataRow GetParentRow( string relationName);  
   public DataRow GetParentRow(string relationName, DataRowVersion version); 
   public DataRow[ ] GetParentRows( DataRelation relation);  
   public DataRow[ ] GetParentRows(DataRelation relation, DataRowVersion version);
   public DataRow[ ] GetParentRows( string relationName);  
   public DataRow[ ] GetParentRows(string relationName, DataRowVersion version);
   public bool HasVersion( DataRowVersion version);  
   public bool IsNull( DataColumn column);  
   public bool IsNull(DataColumn column, DataRowVersion version);
   public bool IsNull( int columnIndex);  
   public bool IsNull( string columnName);  
   public void RejectChanges(  );  
   public void SetColumnError(DataColumn column, string error);
   public void SetColumnError(int columnIndex, string error);  
   public void SetColumnError(string columnName, string error);
   public void SetParentRow( DataRow parentRow);  
   public void SetParentRow(DataRow parentRow, DataRelation relation);
// Protected Instance Methods
   protected void SetNull( DataColumn column);  

Returned By

Multiple types

Passed To

Multiple types

    [ Team LiB ] Previous Section Next Section