Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the paging skills of ADO

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the ADO paging skills". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the ADO paging skills"?

Everyone said: the cursor in the original ADO paging method is inefficient, and it is easy to cause locks, or even lead to crashes. I would like to ask: does this cursor exist on the client, the WEB server, or the database? Are they the same thing? Can they all have cursors according to ADO? Which kind of cursor is the worst?

There is one more question:

I finally found a paging method of TOP combined with max, but today I found that I searched my 10 million database to get 250000 pieces of data, even like search, but using the most primitive ADO method, the discovery speed is also very fast! It's not much slower than TOP and other methods. Why so fast?

Only one DataReader can be opened at a time. In ADO paging, if you open a connection and request two recordsets that use forward-only read-only cursors, ADO implicitly opens the first connection that is not in the connection pool for the cursor's life cycle data store, and then implicitly closes it. In ADO.NET, if you want to open two DataReader on the same data store at the same time, you must explicitly establish two connections, one for each DataReader. This way ADO.NET gives you more control over the use of connection pooling.

By default, DataReader loads the entire line into memory in each Read method. This allows you to randomly access any column of the current row. If random access is not necessary, pass the CommandBehavior.SequentialAccess to the ExecuteReader call to improve performance. This changes the default behavior of DataReader, where data is loaded into memory only when needed. ADO pagination Note CommandBehavior.SequentialAccess requires you to access the returned columns in order. ADO paging means that once you have read a returned column, you cannot read its value again.

If you finish reading data from DataReader, but there are still a lot of unread results waiting, then calling Command's Cancel is better than calling DataReader's Close. Calling the Close of DataReader causes it to retrieve the waiting results and clear the stream before closing the cursor. Call Command's Cancel to delete the results on the server, so when DataReader shuts down, it no longer needs to read the results. ADO paging if you return output parameters from Command, call Cancel to delete them. If you want to read any output parameters, do not call Command's Cancel;*** to call DataReader's Close.

When you use DataReader to retrieve binary large objects, you must pass CommandBehavior.SequentialAccess to the ExecuteReader method call. Because the default behavior of DataReader is to load the entire row into memory in each Read, but because the BLOB can be large, the result may be a BLOB object that uses a lot of memory. SequentialAccess sets the behavior of DataReader to load only the necessary data, and ADO paging then you can use GetBytes or GetChars to control how much data is loaded at a time.

Remember that when using SequentialAccess, ADO paging you cannot access the different fields returned by DataReader out of order. That is, if the query returns three columns, the third is BLOB, and you want to access the data from the first two columns, you must first access the * * columns, and then access the second column before accessing the BLOB data. This is because the data is now returned in order and cannot be accessed again after DataReader has read it.

At this point, I believe that everyone has a deeper understanding of "ADO paging skills", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report