Usage of DataSet in C#
Usage of DataSet in C
#The DataSet class is one of the core members of ADO.NET and is also used in various development projects based on .Net Platform programming languages are the most commonly used classes when developing database applications. Each DataSet has many DataTables and Relationships. RelationShip should also be a kind of table. The special thing is that this table is only used to connect two data tables. Each DataTable has many datarows and datacols, including ParentRelations, ChildRelations and some restrictions such as the restriction that the primary key cannot be repeated.
Each row of DataSet has a RowState property. It mainly reflects whether the current row has been deleted, updated, or unchanged. There are several options as follows: Deleted, Modified, New, and Unchanged.
Any operation on DataSet is completed in the computer cache.
After the data is extracted from the database, the DataSet is the storage place of the data. It is a cache of data from various data sources mapped in the computer memory, so sometimes the DataSet can be regarded as a data container. .
The DataSet object is a data view that can be expressed in XML form and is a data relationship view.
Recommended tutorial: C# video tutorial
There are generally three ways to use DataSet:
1. Put the database The data in the DataSet is filled in through the DataAdapter object. SqlCommand is actually a Command object. Then fill the DataSet with the retrieved data through the Fill method of the DataAdapter.
2. Operate the DataSet through the DataAdapter object to update the database
DataAdapter updates the database with the data in the DataSet through its Update method. When the data contained in the DataSet instance changes, the Update method is called at this time. The DataAdapter will analyze the changes and execute the corresponding command (INSERT, UPDATE or DELETE), and use this command to update the data in the database.
3. Load XML data stream or text into DataSet
The data in DataSet can be created from XML data stream or document. To load XML data streams and documents into a DataSet, you can use the ReadXml method of the DataSet object.
Data binding is divided into two categories: simple data binding and complex data binding. Components suitable for simple data binding generally include Label, TextBox, etc., and components suitable for complex data binding generally include DataGrid, ListBox, ComboBox, etc.Simple data
Binding generally uses the Add method of the DataBindings property in these components to combine a row in a DataTable in the DataSet with a property of the component. Bind together to achieve the effect of displaying data.
For example: textBox1.DataBindings.Add ( "Text" , dsDataSet1, " Customers. CustomerID ") ;Complexity data binding
Generally, data binding is completed by setting the DataSource property and DisplayMember property of the component. The DataSource attribute value is generally set to the DataSet to be bound, and the DisplayMember attribute value is generally set to the data table or a column in the data table to be bound.
For example:dataGrid1.DataSource = dsDataSet1 ; dataGrid1.DataMember = " Customers " ;
Introduction to Programming Tutorial
, please pay attention to the PHP Chinese website!The above is the detailed content of Usage of DataSet in C#. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Active Directory with C#. Here we discuss the introduction and how Active Directory works in C# along with the syntax and example.

Guide to C# Serialization. Here we discuss the introduction, steps of C# serialization object, working, and example respectively.

Guide to Random Number Generator in C#. Here we discuss how Random Number Generator work, concept of pseudo-random and secure numbers.

Guide to C# Data Grid View. Here we discuss the examples of how a data grid view can be loaded and exported from the SQL database or an excel file.

Guide to Factorial in C#. Here we discuss the introduction to factorial in c# along with different examples and code implementation.

Guide to Patterns in C#. Here we discuss the introduction and top 3 types of Patterns in C# along with its examples and code implementation.

Guide to Prime Numbers in C#. Here we discuss the introduction and examples of prime numbers in c# along with code implementation.

The difference between multithreading and asynchronous is that multithreading executes multiple threads at the same time, while asynchronously performs operations without blocking the current thread. Multithreading is used for compute-intensive tasks, while asynchronously is used for user interaction. The advantage of multi-threading is to improve computing performance, while the advantage of asynchronous is to not block UI threads. Choosing multithreading or asynchronous depends on the nature of the task: Computation-intensive tasks use multithreading, tasks that interact with external resources and need to keep UI responsiveness use asynchronous.
