Gets or sets a value indicating whether the column should store data in a fashion optimized for sparse data patterns.
[Visual Basic] Public Property Sparse As Boolean [C#] public bool Sparse {get; set;} [C++] public: __property bool get_Sparse(); public: __property void set_Sparse(bool); [JScript] public function get Sparse() : Boolean; public function set Sparse(Boolean);
true if the column is marked as a sparse column; otherwise, false. The default is false.
Exception Type | Condition |
---|---|
ArgumentException | The column already has data stored. |
This property is useful for irregular data. Setting the property to true indicates that the column is not always there, allowing the system to handle memory and performance better.
The OnPropertyChanged event occurs when the property value is successfully changed.
The following example creates a new DataColumn and sets the Sparse property to true.
[Visual Basic]
Private Sub AddColumn() Dim cols As ColumnsCollection Dim myCol As DataColumn Dim myTable As New DataSet1.Tables("Prices") cols = myTable.Columns myCol = cols.Add("Total") With myCol .DataType = System.Type.GetType("System.Currency") .ReadOnly = True .Expression = "UnitPrice * Quantity" .Unique = False .Sparse = True End With End Sub
DataColumn Class | DataColumn Members | System.Data Namespace