ADO.NET object model

zhaozj2021-02-16  120

ADO.NET is specifically designed to help developer development efficient multi-layer database applications. The ADO.NET object model can be divided into two categories: a class is "connected", a class of "disconnected" object, which allows the query result to be processed in memory.

"Connected" object model as the name suggests, it is directly connected to the database; "Disconnect" object model can be said to be based on the "connected" object model, because it must first "connection" "Operation can get the desired results.

Lifting an example:

SqlConnection Con = New SqlConnection ("Server = localhost; Database = DB, UID = SA, PWD =;");

Sqldataadapter ad = new sqldataadapter ("Select * from table", con);

DataSet DS = New Dataset ();

Ad.fill (DS, "Table");

/ (Note that the result of the query from the database has been put in a DataSet object. From this point, you will start using the "disconnected" object model to operate the database, and the DataSet object is in memory. "Virtual Data Table", you can do anything without affecting the database, you can sort, modify, query, increase, delete it. And if you want to change the content of the database, you can also operate through the DataSet object, very simple, calling its Update () method to complete the update database. It is also possible to use its getChanges () method to get only changed rows, it returns a DataSet, this Dataset is different from that of the call getChanges () method, which is just a piece of sub-table, which is changed. This method can greatly improve the performance of multi-layer ADO.NET applications. The DataSet class also has a MERGE method to merge the data of the two DataSet objects, and the ADO.NET defaults to override rows in the DataSet that is called Merge () method.

ADO.NET also provides a strong type of DataSet object: it can help you simplify the process of establishing data access applications. For example: There is a table called Table, where there is a column that you can access this column like this:

VB.NET: DIM DS AS Dataset

Console.writeline (ds.table (0) .Column); (Table (0). Representing the first line in the table table)

C #: DataSet DS;

Console.writeline (DS.Table [0] .COLUMN); (Table [0]. Representing the first line in the table table)

Is it very simple: ^ _ ^

There are still many things in DataSet, such as: DataTable, DataView, DataRow, Datacolumn, DataRelation, Constraint, a lot of good things, will be mentioned in the later log!

转载请注明原文地址:https://www.9cbs.com/read-10902.html

New Post(0)