Handling Databases In Code

The DataSet Class

A dataset is a cache of data retrieved from a database, and it's the major component of ADO.NET.
A DataSet object is made up of a collection of DataTable objects that you can relate to each other using DataRelation objects. You also can guarantee data integrity with the UniqueConstraint and ForeignKeyConstraint objects.

The DataTable Class

DataTable objects store data tables, and as such, they're central to datasets and data views. More on data views see Data Access with ADO.NET.
In code, you create data tables and then add the fields in each row to them.

Example
A new table called Table1 is created. Also a DataColumn object is created. This is configured and add it to table's Columns collections.
[[source]]
Dim Table1 As DataTable
Table1 = New DataTable("Employees")
Dim FirstName As DataColumn = New DataColumn("First Name")
FirstName.DataType = System.Type.GetType("System.String")
Table1.Columns.Add(FirstName)
[[/source]]

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.