What are the functions of sqlconnection, sqlcommand, sqldataadapter, sqldatareader, and dataset?

Source: Internet
Author: User
1 God said, to connect to the database, so there is sqlconnection (database connection, Configure connection string, user name and password, etc.) 2 God said, to execute SQL statements. 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 get 5 from the cycle of datarow one by one. 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 thinks that the visual things are God's favorite (user = God), so they 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. 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 just want to display a piece of data... drag it... you just want to display a report to the next office. Why do you think so much.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.