How to use ADO.NET structure DataSet
This article introduces the knowledge of "how to use ADO.NET structure DataSet". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The ADO.NET structure is basically divided into two parts: DataSet and Managed Provider. The following is a brief overview of DataSet, its common approach. DataSet is an in-memory database that provides a consistent programming model, regardless of where it comes from. DataSet consists of a set of tables, columns, rows, constraints, and relationships. The object model for DataSet is as follows:
A data sheet (DataTable) refers to a memory data table. It contains a collection of columns (ColumnsCollection) that represent the schema of the table. A data table also contains a collection of columns (RowsCollection) that represents the data owned by the table. It remembers the original state as well as the current state and tracks the changes that have taken place.
To use a data table, the user must include a System.Data.
ADO.NET structure creates a data table
DataTable has two constructors:
Public DataTable () public DataTable (string tableName)
Add columns to the datasheet
DataTable contains a collection of DataColumn objects. This collection of columns defines the structure of the table. To add a new column to the collection, you can use the collection's Add method. In the following example, we use the Add method of the ColumnsCollection class to add three columns to a data table; this method specifies the ColumnName and DataType properties.
1 DataColumn dc = null; 2 DataTable dt = new DataTable ("test"); 3 dc = dt.Columns.Add ("CustID", System.Type.GetType ("System.Int32")); 4 dc = dt.Columns.Add ("CustomerNameLast", System.Type.GetType ("System.String")); 5 dc = dt.Columns.Add ("CustomerNameFirst", System.Type.GetType ("System.String")) 6 dc = dt.Columns.Add ("Purchases", System.Type.GetType ("System.Double")); the Add method of ColumnsCollection on DataTable has two overloaded (overload) functions: Public DataColumn Add (String columnname, Type type) Public DataColumn Add (String columnname) "how to use ADO.NET structure DataSet". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!