2. Read the data
ADO.NET Apps To read data from the data source, you must create a connection object. This connection object can be SQLConnection or Adoconnection, depending on the target provider used. Need to keep in mind, although here Not recommending, but you can also use the ADO .NET class to connect to the SQL Server database. This method is unique, the code needs to pass an unnecessary extra code layer. First it will transfer the ADO's hosted provider, then ADO's hosted provider calls the SQL Server OLE DB provider. Like the OLE DB provider, the SQL Server managed provider directs data directly.
About ADO and ADO.NET on the connection object is the biggest difference in the ADO.NET connection does not support the CursorLocation property. It is not as good as it is a document BUG, it is better to think that this is a design problem of a ready-to-have controversial. To enforce it The data is a centered benchmark, ADO.NET has no display implementation of the cursor.
In ADO, you are accustomed to extracting records using cursors from databases or other OLE DB-compatible data sources, you can choose the client or server-side cursor, each of which has several pre-set cursor types. More in ADO.NET is to extract data from the data source and provide new programming interfaces for reading and analyzing data.
In ADO, you can create a RecordSet object by specifying connection and command text. There are some rules for the location and type Recordset of the cursor. You can read the data as follows.
Create a static copy of the selected record in memory, and then processes the copy when disconnected from the data source, and the ADO is called a static cursor.
By fast, forward, read-only cursor is scrolling data, ADO is called only forward cursors.
Access the data through the server-side cursor, you need a good connection, but you can detect information entered by other connection users on different levels, and Ado is called: dynamic cursor.
Both of the head are operated on the disconnected Recordsets and read information from the client cache, and the first two ways are often used in the Web-oriented environment and the new N-Tier system.
In ADO, all of these ways correspond to different types of cursors. In the text, you will find that ADO.NET is different from ADO, but it has all the features of ADO. Relative photo, your code will Data is extracted from the actual data source and its physical storage medium and format.
ADO.NET enables DataSet and DataReader to extract data from the data source. The former is a cache recorded in memory, you can access and modify from any direction. The latter is a highly optimized object, in a read-only record concentration Move forward only. Note: DataSet looks like a static cursor, but in fact, in .NET, the DataReader object corresponds to the ADO read-only cursor.
In ADO.NET, although no support is provided for the server-side cursors, this doesn't mean that you can't use a cursor. In fact, the step you need to do is to enter an ADO library in .NET. You only need to be in References Click Right click on the Node to run a local ADO object in your own program.
But I personally think that when you want to turn to .NET, please consider carefully. First, please enter the ADO completely, this will not spend too much time and energy, this is the first step toward .NET,. But, This is just the first step of the long march and also one step to .NET must have. The true value of .NET is based on a uniform, sustained and stable interface, and the wide application of local Classes. About Com Libraries is It can be supported, reasonable, but not encouraged because it is just a short-term solution, or a transitional step.
When you want to start using ADO.NET, consider this fact: ADO.NET unified data container class programming interface, so, no matter what type of program: Windows Form, Web Form, or Web Service, You have to concentrate on relevant data in the same group. Regardless of the backend data source is SQL Server Database, or the OLE DB provider, the XML file, or array, you can use the same method and properties. Treatment.
If you insist on using ADO in the .NET world, please prepare to face some other impact, for example, you need additional code to use RecordSet from the data binding control.