In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
one。 Concept understanding
The name ADO.NET, which originated from ADO (ActiveX Data Objects), is a library of COM components used to access data in previous Microsoft technologies. The ADO.NET name is used because Microsoft wants to show that this is the preferred data provider in the NET programming environment.
two。 Class library composition
Connection class
Database connector. The connection help indicates the database server, database name, user name, password, and other parameters required to connect to the database. The Connection object is used by the Command object so that you can know which data source the command is executing on.
ADO.NETCommand object
After successfully establishing a connection with the data, you can use the Command object to execute commands such as query, modification, insert, delete, etc.; the common methods of Command objects are ExecuteReader () method, ExecuteScalar () method, and ExecuteNonQuery () method; insert data can be inserted using the ExecuteNonQuery () method to execute the insert command.
ADO.NETDataReader class
Data readers; many data operations require developers to read only a string of data. The DataReader object allows the developer to get the results from the SELECT statement of the Command object. For performance reasons, the data returned from DataReader is fast and only a "forward" data stream. This means that developers can only pull data from the data stream in a certain order. This is good for speed, but if developers need to manipulate data, it is better to use DataSet.
ADO.NETDataSet object
A DataSet object is a representation of data in memory. It includes multiple DataTable objects, while DataTable contains columns and rows, just like a table in a normal database. Developers can even define relationships between tables to create master-slave relationships (parent-child relationships). DataSet is used in specific scenarios-- to help manage data in memory and support data disconnect operations. DataSet is the object used by all Data Providers, so it doesn't require a special prefix like Data Provider.
ADO.NETDataAdapter class
The data adapter acts as a bridge between the database and DataSet; sometimes the data used by developers is mainly read-only, and developers rarely need to change it to the underlying data source. Similarly, some situations require caching data in memory to reduce the number of times that unchanged data is called by the database.
DataAdapter helps developers deal with the above situations easily by breaking the model. DataAdapter populates (fill) the DataSet object when continuous changes to read and write operations to the database in a single batch are returned to the database. DataAadapter contains references to connection objects and to automatically open or close connections when reading or writing to a database. In addition, DataAdapter contains Command object references to SELECT, INSERT, UPDATE, and DELETE operations of the data. The developer will define a DataAadapter for each Table in the DataSet, which will take care of all connections to the database for the developer. So what the developer will do is tell DataAdapter when to load or write to the database.
ADO.NETDataTable class
DataTable is a data grid control. It can be applied to VB and ASP. It can simply bind the database without code. It has a Microsoft-style user interface.
Instantiation of DataTable and addition of columns:
DataTable dt = new DataTable ()
Dt.Columns.Add ("ID")
Dt.Columns.Add ("Name")
DataRow dr = dt.NewRow ()
Object [] objs = {1, "Name"}
Dr.ItemArray = objs
Dt.Rows.Add (dr)
This.dataGridView1.DataSource = dt
SQLTransaction
Database connection things.
three。 Namespace
When using ADO.net 's classes, we need to refer to different namespaces, such as SQL data sources:
Using System.Data.SqlClient
When I studied before, I didn't quite understand these things. I used them in my work. I summed them up for reference. If there are any inadequacies, please correct them.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.