inicio mail me! sindicaci;ón

Use Filter retrieves 2 times when realize information

Ponder over a problem: On the foundation that how implementation retrieves in first time to undertake 2 times retrieval?

Normally, our practice is save when first time retrieval retrieve a condition, when retrieving the 2nd times all right combination retrieves a condition twice to have new inquiry to the database, be like:

First time retrieval: Select * From Table Where Age>18

Retrieve the 2nd times: Select * From Table Where Age>18 And Name Like ‘zh%’

Although can achieve the result that we want such doing, but the individual on efficiency thought to call a discount greatly however!

Can the record volume that cache first time retrieves, when retrieving the 2nd times, be in only the record of cache undertakes on collect, is new undertake inquiring to the database?

RecordSet object has an attribute Filter, its action is the record volume that is about to show with control through adding a requirement, but do not affect originally record volume! Fall how to come true 2 times to retrieve with it in light of us:

It is quotative content below:
<%
Dim OConn, ORs
Set OConn=Server.CreateObject(”ADODB.Connection” )OConn.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” Server.MapPath(”db1.mdb” )
Set Ors = Server.CreateObject(”ADODB.RecordSet” )Ors.Open "select * From T1 Where Age>20" , OConn, 1, 2

Response.Write ” retrieves: Select * From T1 Where Age>20<br/> "
Response.Write “———————————-<br/><br/> "
Do While Not Ors.Eof
Response.Write Ors(”name” )&”:” &Ors(”age” )&"<br/> "Ors.MoveNext
Loop
Response.Write ” add up to:” &Ors.RecordCount&"<br/> "
Response.Write “———————————-<br/><br/> "

Response.Write ” retrieves 2 times: King of Filter(name Like ‘ %’)<br/> "
Response.Write “———————————-<br/><br/> "%’ of king of Ors.Filter = “name Like ‘ “
If Not(oRs.Eof And Ors.Bof) Then Ors.MoveFirst
Do While Not Ors.Eof
Response.Write Ors(”name” )&”:” &Ors(”age” )&"<br/> "Ors.MoveNext
Loop
Response.Write ” add up to:” &Ors.RecordCount&"<br/> "
Response.Write “———————————-<br/> "

Ors.Close
Set Ors = NothingOConn.Close
Set OConn = Nothing
%>

Result:

In all 2 pages: On one page 1[2] Issue one page

Bookmark:Digg Del.icio.us Reddit

Leave a Comment