In asp.net, reading data from a database can be used in DataReader and DataSet 2 ways,
The difference between the two is as follows:
Reading data using a DataSet object generally requires the following 5 steps:
(1) Establish a database link, you can choose SqlConnection or 01edbConnection.
(2) Save the query in a SqlDataAdapter or OleDbDataAdapter object.
(3) Fills the data into a DataTable in the dataset using the Fill method of the DataAdapter object.
(4) To create a DataView object for the DataTable object to display the data, this step can be omitted.
(5) Bind the DataView or dataset to the server control.
The following 6 steps are generally required to read data using DataReader:
(1) Establish a database link, you can choose SqlConnection or OleDbConnection.
(2) Open the database link using the Connection object's Open method.
(3) Save the query in a SqlCommand or OleDbCommand object.
(4) The ExecuteReader method of the Command object is invoked to read the data into the DataReader object.
(5) The read or get method of the call DataReader reads-pen data so that it does not display.
(6) Call the Close method of the connection object and turn off the data sequence link.
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