Recommended: ASP 3.0 Advanced Programming (31) 7.1.2 The discovery and handling of semantic or runtime errors is annoying, but you will encounter some really exciting other type of errors in programming - semantic error (semantic error), or&ld
Think about a question: How to achieve secondary search based on the first search?
Usually, our approach is to save the search conditions during the first search, and combine two search conditions during the second row search to perform a new query on the database, such as:
First search: Select * from table where age>18
Second search: Select * from table where age>18 and name like 'zh%'
Although doing this can achieve the results we want, I personally think that efficiency has been greatly reduced!
Can the first searched record set can be cached, and the second search will only be performed on the cached record set, instead of re-querying the database?
The RecordSet object has a property Filter, which is used to control the record set to be displayed by adding conditions, but does not affect the original record set! Let's take a look at how to use it to achieve secondary retrieval:
The following is the quoted content: <% 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 One-time search: 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 Total: & ors.RecordCount & <br/> Response.Write ----------------------------------<br/><br/> Response.Write Secondary search: Filter(name like 'king%')<br/> Response.Write ----------------------------------<br/><br/> ors.Filter = name like 'king%' 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 Total: & ors.RecordCount & <br/> Response.Write ----------------------------------<br/> ors.Close Set ors = Nothing oConn.Close Set oConn = Nothing %> |
result:
Share: Deeply understand the magical functions of FSO in ASP In ASP, FSO means File System Object, which is a file system object. The computer file system we are going to manipulate refers to being located on the web server. So, make sure you have the right permissions for this. Ideally, you can use your own machine
2 pages in total Previous page 12 Next page