Asp.net has such knowledge: dataset, datatable, datareader, and dataadapter.
Dataset is a method used to connect to SQL. It means to store database copies in an application. When an application starts running, it saves database-related data to dataset.
Datatable indicates a table with data in memory. You can use view to obtain a custom view of a table that may include a filtering view or a cursor position.
The datareader object is the simplest way to read the database. It can only read, cannot write, and is read from the beginning to the end. It cannot read only a piece of data, but it occupies a small memory and is fast.
The dataadapter object is used to read data from the database. It can read and write data. A piece of data is too powerful, but it occupies more memory than datareader and is slow.
1. God said that to connect to the database, sqlconnection (database connection, connection string configuration, user name, password, and so on) is available)
2. God said that SQL statements should be executed. Therefore, SQL commands are directly translated into SQL commands. Each sqlcommand has commandtext and parameters text and parameters. Complete the command and execute it. Of course, make sure that the connection is open. Nothing can be done without connection.
3 God believes that there is a way to read the returned results, so there is a datareader. You can read (read) one by one until the last one.
4 God believes that it is good to find a place to store the execution results. So we have dataset. This is perfect. Basically, it can store various data and relationships, which is much more convenient than datareader. There are dataview and able one by one. For your query results, of course, datatable can also be obtained from one cycle of datarow.
5. God thinks the above steps are too complicated -_-!
Therefore, the sqldataadapter (translated as the SQL data adapter, adapter mode) is used to encapsulate and simplify the above steps. You only need to create a new sqldataadapter, fill in the statement for it, and directly fill it to dataset. In this way, you have everything. You only need two steps!
6. Microsoft believes that the visualization is God's favorite (user = God)
So we have one sqladapter control, dataset control, and gridview control .... you can drag the window (winform) or page (Asp. net web application, etc.) set several attributes and bind them. You do not need to write a line of code. So that common network administrators and clerks can become potential users. (Although this method is ignored by "professional programmers)
7. Suggestions:
If you like efficiency, use command + datareader to handle it yourself (Be careful not to make it worse)
If you like convenience, use adapter + dataset in large quantities. After all, binding is too time-saving.
If you want to display data, you just want to display a report to the next office. Why do you think so much.