
InternetUnicodeHTMLCSSScalable Vector Graphics (SVG)Extensible Markup Language (xml) ASP.Net TOCASP.NetMiscellaneous FeatureASP.NET ScriptingASP.NET Run-time Object System.IO Namespace System.DataDataSet Draft for Information Only
Content
System.Data Namespace Component
System.Data Namespace ComponentThe System.Data namespace provides access to classes that represent the ADO.NET architecture. ADO.NET lets you build components that efficiently manage data from multiple data sources. DataColumn ClassDefinition
Represents the schema of a column in a DataTable. In this article
public class DataColumn : System.ComponentModel.MarshalByValueComponent
ExamplesThe following example creates a DataTable with several DataColumn objects. C#private void MakeTable()
{
// Create a DataTable.
DataTable table = new DataTable("Product");
// Create a DataColumn and set various properties.
DataColumn column = new DataColumn();
column.DataType = System.Type.GetType("System.Decimal");
column.AllowDBNull = false;
column.Caption = "Price";
column.ColumnName = "Price";
column.DefaultValue = 25;
// Add the column to the table.
table.Columns.Add(column);
// Add 10 rows and set values.
DataRow row;
for(int i = 0; i < 10; i++)
{
row = table.NewRow();
row["Price"] = i + 1;
// Be sure to add the new row to the
// DataRowCollection.
table.Rows.Add(row);
}
}
RemarksThe DataColumn is the fundamental building block for creating the schema of a DataTable. You build the schema by adding one or more DataColumn objects to the DataColumnCollection. For more information, see Adding Columns to a DataTable. Each DataColumn has a DataType property that determines the kind of data the DataColumn contains. For example, you can restrict the data type to integers, or strings, or decimals. Because data that is contained by the DataTable is typically merged back into its original data source, you must match the data types to those in the data source. For more information, see Data Type Mappings in ADO.NET. Properties such as AllowDBNull, Unique, and ReadOnly put restrictions on the entry and updating of data, thereby helping to guarantee data integrity. You can also use the AutoIncrement, AutoIncrementSeed, and AutoIncrementStep properties to control automatic data generation. For more information about AutoIncrement columns, see Creating AutoIncrement Columns. For more information, see Defining Primary Keys. You can also make sure that values in a DataColumn are unique by creating a UniqueConstraint and adding it to the ConstraintCollection of the DataTable to which the DataColumn belongs. For more information, see DataTable Constraints. To create a relation between DataColumn objects, create a DataRelation object and add it to the DataRelationCollection of a DataSet. You can use the Expression property of the DataColumn object to calculate the values in a column, or create an aggregate column. For more information, see Creating Expression Columns. Constructors
Properties
Methods
Events
Applies to.NET Core3.0 Preview 8 2.2 2.1 2.0.NET Framework4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6 4.5.2 4.5.1 4.5 4.0 3.5 3.0 2.0 1.1.NET Standard2.1 Preview 2.0Xamarin.Android7.1Xamarin.iOS10.8Xamarin.Mac3.0Thread SafetyThis type is safe for multithreaded read operations. You must synchronize any write operations. See also
ExamplesExamples of DataColumn Class
ASP.NET Code Input: HTML Web Page Embedded Output: Source/Reference©sideway ID: 201100007 Last Updated: 11/7/2020 Revision: 0 Ref: References
Latest Updated Links
Nu Html Checker 53 na |
![]() Home 5 Business Management HBR 3 Information Recreation Hobbies 8 Culture Chinese 1097 English 339 Travel 18 Reference 79 Computer Hardware 257 Software Application 213 Digitization 37 Latex 52 Manim 205 KB 1 Numeric 19 Programming Web 289 Unicode 504 HTML 66 CSS 65 SVG 46 ASP.NET 270 OS 431 DeskTop 7 Python 72 Knowledge Mathematics Formulas 8 Set 1 Logic 1 Algebra 84 Number Theory 206 Trigonometry 31 Geometry 34 Calculus 67 Engineering Tables 8 Mechanical Rigid Bodies Statics 92 Dynamics 37 Fluid 5 Control Acoustics 19 Natural Sciences Matter 1 Electric 27 Biology 1 |
Copyright © 2000-2025 Sideway . All rights reserved Disclaimers last modified on 06 September 2019